Run command creates pod instead of deployment on Azure Kubernetes

4/22/2020

When I use the kubectl run command instead of creating a deployment it creates a pod/selenium-node-chrome and as a result, I am unable to scale the selenium-node-chrome using the replicas command.

PS C:\Users\Test> kubectl run selenium-node-chrome --image selenium/node-chrome:latest --env="HUB_PORT_4444_TCP_ADDR=selenium-hub" --env="HUB_PORT_4444_TCP_PORT=4444"
pod/selenium-node-chrome created
PS C:\Users\Test> kubectl scale deployment selenium-node-chrome --replicas=5
Error from server (NotFound): deployments.extensions "selenium-node-chrome" not found

The video tutorial that I followed successfully created deployment "selenium-node-chrome" after running the same command. Please I need help and I am new to Kubernetes. Thanks.

-- melleck
azure-kubernetes
kubernetes
kubernetes-deployment
kubernetes-pod
selenium-grid

2 Answers

4/22/2020

All generators are deprecated in Kubernetes version 1.18. From the docs here

Note: All kubectl generators are deprecated. See the Kubernetes v1.17 documentation for a list of generators and how they were used.

You can use kubectl create deployment my-dep --image=busybox to create a deployment.

Also to create a yaml file use kubectl create deployment my-dep --image=busybox --dry-run=client -o yaml > deployment.yaml and then edit the yaml file to add env or any other details and apply the yaml via kubectl apply -f deployment.yaml

-- Arghya Sadhu
Source: StackOverflow

4/22/2020

You should use a generator

kubectl run selenium-node-chrome \
  --image selenium/node-chrome:latest \
  --env="HUB_PORT_4444_TCP_ADDR=selenium-hub" \
  --env="HUB_PORT_4444_TCP_PORT=4444" \
  --generator=deployment/apps.v1beta1

https://v1-17.docs.kubernetes.io/docs/reference/kubectl/conventions/#generators

-- 4c74356b41
Source: StackOverflow