How to Deploy YAMLs with Deprecated Parameters on Kubernetes 1.16.0
Carlos Nogueira
Posted on October 17, 2019
The Kubernetes version 1.16.0 stopped to serve the following deprecated APIs:
NetworkPolicy (in the extensions/v1beta1 API group):
Migrate to use the networking.k8s.io/v1 API, available since v1.8. Existing persisted data can be retrieved/updated via the networking.k8s.io/v1 API.PodSecurityPolicy (in the extensions/v1beta1 API group):
Migrate to use the policy/v1beta1 API, available since v1.10. Existing persisted data can be retrieved/updated via the policy/v1beta1 API.DaemonSet, Deployment, StatefulSet, and ReplicaSet (in the extensions/v1beta1 and apps/v1beta2 API groups)
You must check your older YAMLs. But changing the listed parameters in all files can be an exhausting task.
An option would be to convert the older files.
For example, lets deploy a NGINX using the file nginx.yaml.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
run: nginx
name: deploy-nginx
spec:
selector:
matchLabels:
run: nginx
template:
metadata:
labels:
run: nginx
spec:
containers:
- image: nginx
name: nginx
The files nginx.yaml sets apiVersion: extensions/v1beta1 and it's compatible with kubernetes older versions, but not run on The last.
To convert the older YAML, using client 1.16 execute kubectl with the option convert:
kubectl convert -f nginx.yaml
Command screen output would be like:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
run: nginx
name: deploy-nginx
spec:
progressDeadlineSeconds: 2213489811
revisionHistoryLimit: 2213489811
selector:
matchLabels:
run: nginx
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
run: nginx
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartiPolicy: Always
schedulerName: defaul-scheduler
securityContext: {}
terminationGracePeriodSeconds: 28
status: {}
Paste the command output to a file(ex: nginxOUT.yaml)
kubectl convert -f nginx.yaml > nginxOUT.yaml
Deploy
Using output file
kubectl create -f nginxOUT.yaml
Directly with the older file
kubectl convert -f nginx.yaml | kubectl create -f -
References
https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/
Posted on October 17, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.