I have this very basic YAML file which i tried to migrate from kubectl v1.14 to v1.16. I changed extensions/v1beta1
to apps/v1
and I added selectors as well since they were mandatory in v1.16.
My original YAML file which worked fine in v1.14
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: cpx-ingress-hotdrinks
spec:
replicas: 1
template:
metadata:
name: cpx-ingress-hotdrinks
labels:
app: cpx-ingress-hotdrinks
app1: exporter
annotations:
NETSCALER_AS_APP: "True"
spec:
serviceAccountName: cpx
containers:
- name: cpx-ingress-hotdrinks
image: "quay.io/citrix/citrix-k8s-cpx-ingress:13.0-36.28"
securityContext:
privileged: true
env:
- name: "EULA"
value: "yes"
- name: "KUBERNETES_TASK_ID"
value: ""
- name: "NS_MGMT_SERVER"
value: "10.106.157.115"
- name: "NS_MGMT_FINGER_PRINT"
value: "2C:77:B6:BA:E0:29:F4:01:53:D5:71:B5:3E:D0:1D:54:CA:75:E5:C1"
- name: "NS_HTTP_PORT"
value: "9080"
- name: "NS_HTTPS_PORT"
value: "9443"
- name: "LOGSTREAM_COLLECTOR_IP"
value: "10.106.157.115"
imagePullPolicy: IfNotPresent
# Add cic as a sidecar
- name: cic
image: "in-docker-reg.eng.citrite.net/cic-dev/cic:357"
env:
- name: "EULA"
value: "yes"
- name: "NS_IP"
value: "127.0.0.1"
- name: "NS_PROTOCOL"
value: "HTTP"
- name: "NS_PORT"
value: "80"
- name: "NS_DEPLOYMENT_MODE"
value: "SIDECAR"
- name: "NS_ENABLE_MONITORING"
value: "YES"
- name: "NS_LOGPROXY"
value: "10.106.157.115"
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
args:
- --ingress-classes
hotdrink
- --default-ssl-certificate
$(POD_NAMESPACE)/hotdrink-secret
imagePullPolicy: IfNotPresent
---
I modified the files for v1.16. My YAML files now look like this
apiVersion: apps/v1
kind: Deployment
metadata:
name: cpx-ingress-hotdrinks
spec:
replicas: 1
selector:
matchLabels:
app: cpx-ingress-hotdrinks
app1: exporter
template:
metadata:
name: cpx-ingress-hotdrinks
labels:
app: cpx-ingress-hotdrinks
app1: exporter
annotations:
NETSCALER_AS_APP: "True"
spec:
serviceAccountName: cpx
containers:
- name: cpx-ingress-hotdrinks
image: "quay.io/citrix/citrix-k8s-cpx-ingress:13.0-36.28"
#image: "cpx:fix"
securityContext:
privileged: true
env:
- name: "EULA"
value: "yes"
- name: "KUBERNETES_TASK_ID"
value: ""
- name: "NS_MGMT_SERVER"
value: "10.106.157.115"
#value: "10.106.157.116"
#value: "10.102.103.177"
- name: "NS_MGMT_FINGER_PRINT"
value: "2C:77:B6:BA:E0:29:F4:01:53:D5:71:B5:3E:D0:1D:54:CA:75:E5:C1"
# value: "9C:13:79:F5:90:AF:6C:81:91:DE:D3:86:6E:50:7F:EA:A2:62:EE:E3"
#value: "2C:17:0C:25:1D:ED:77:86:45:C6:D0:AE:C4:9F:F2:CA:7A:B2:BB:95"
- name: "NS_HTTP_PORT"
value: "9080"
- name: "NS_HTTPS_PORT"
value: "9443"
- name: "LOGSTREAM_COLLECTOR_IP"
value: "10.106.157.115"
#value: "10.106.157.116"
#value: "10.102.103.177"
#- name: "NS_CPX_LITE"
# value: "1"
imagePullPolicy: IfNotPresent
# Add cic as a sidecar
- name: cic
image: "in-docker-reg.eng.citrite.net/cic-dev/cic:357"
env:
- name: "EULA"
value: "yes"
- name: "NS_IP"
value: "127.0.0.1"
- name: "NS_PROTOCOL"
value: "HTTP"
- name: "NS_PORT"
value: "80"
- name: "NS_DEPLOYMENT_MODE"
value: "SIDECAR"
- name: "NS_ENABLE_MONITORING"
value: "YES"
- name: "NS_LOGPROXY"
value: "10.106.157.116"
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
args:
- --ingress-classes
hotdrink
- --default-ssl-certificate
$(POD_NAMESPACE)/hotdrink-secret
imagePullPolicy: IfNotPresent
---
But on running this I get the following error
error: error validating "/root/config/cpx.yaml":
error validating data: [ValidationError(Deployment.spec.template):
unknown field "selector" in io.k8s.api.core.v1.PodTemplateSpec, ValidationError(Deployment.spec):
missing required field "selector" in io.k8s.api.apps.v1.DeploymentSpec];
if you choose to ignore these errors,
turn validation off with --validate=false
What could be causing this issue? I followed all the steps in the kubectl depreciation manual ? It should ideally work in v1.16 as well.
Moving from extensions/v1beta1
to apps/v1
also requires informing the selector
field, this is no longer inferred from the pod template.
Notice the optional at the extenstions/v1beta1
type: https://github.com/kubernetes/api/blob/5524a3672fbb1d8e9528811576c859dbedffeed7/extensions/v1beta1/types.go#L107-L110
See that same block at the new apps/v1
type: https://github.com/kubernetes/api/blob/5524a3672fbb1d8e9528811576c859dbedffeed7/apps/v1/types.go#L276-L279
Add a selector that matches your Pod template's label and you should be good.