skip to Main Content

While creating a deployment using command

kubectl create deploy nginx --image=nginx:1.7.8 --replicas=2 --port=80

I am getting error Error: unknown flag: --replicas

controlplane $ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:58:59Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:50:46Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
controlplane $ kubectl create deploy nginx --image=nginx:1.7.8 --replicas=2 --port=80
Error: unknown flag: --replicas
See 'kubectl create deployment --help' for usage.

Could anyone please help me with the reason for this as this command is working on other Kubernetes clusters?

3

Answers


  1. It looks like that --replicas and --port flags were added in version 1.19 based on the v1-19 release notes and that’s why you are seeing the error.

    So, you need the minimum version 1.19 to able to use the replicas and port flags as part of the kubectl create deployment command.

    You can however use the kubectl scale/expose command after creating the deployment.

    Relevant PR links for replicas and port.

    Login or Signup to reply.
  2. You may try to put a blank character between — and the commands
    For example

    kubectl create deploy nginx –image=nginx:1.7.8 — replicas=2

    It’s work for me.

    Login or Signup to reply.
  3. if you trying to update the replica parameter in Azure release pipeline inside the help upgrade command then refer to the following link
    Overriding Helm chart values

    here it explains that you can override the parameters inside the vallues.yaml file with set command like this

    helm upgrade $(RELEASE_ENV) --install  
    infravc/manifests/helm/web 
    --set namespace=$(NAMESPACE) 
    --set replicas=$(replicas) 
    --set replicasMax=$(replicasMax) 
    --set ingress.envSuffix=$(envSuffix) 
    --set ENV.SECRET=$(appSecretNonprod) 
    --set ENV.CLIENT_ID=$(clientIdNonprod) 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search