examples
examples copied to clipboard
--replicas flag has been deprecated
Commands in chapter 8 rely on the depreciated replicas. This is several places throughout the book.
It was removed in 1.18.
https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.18.md#deprecation-4
kubectl run be-default \
--image=gcr.io/kuar-demo/kuard-amd64:blue
--replicas=3
--port=8080 Flag --replicas has been deprecated, has no effect and will be removed in the future. pod/be-default created
The closest alternative with which I could come up for a command such as
kubectl run alpaca-prod --image=gcr.io/kuar-demo/kuard-amd64:blue --replicas=3 --port=8080 --labels="ver=1,app=alpaca,env=prod"
would be to do the following:
Run
kubectl create deployment alpaca-prod --image=gcr.io/kuar-demo/kuard-amd64:blue --replicas=3 --port=8080 --output yaml --dry-run=client >alpaca-prod.yaml
The command will create alpaca-prod.yaml with the content
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: alpaca-prod
name: alpaca-prod
spec:
replicas: 3
selector:
matchLabels:
app: alpaca-prod
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: alpaca-prod
spec:
containers:
- image: gcr.io/kuar-demo/kuard-amd64:blue
name: kuard-amd64
ports:
- containerPort: 8080
resources: {}
status: {}
Edit metadata.labels, spec.selector.matchLabels, spec.template.metadata.labels to included the labels from the run command:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
name: alpaca-prod
labels:
app: alpaca
ver: "1"
env: prod
spec:
replicas: 3
selector:
matchLabels:
app: alpaca
ver: "1"
env: prod
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: alpaca
ver: "1"
env: prod
spec:
containers:
- image: gcr.io/kuar-demo/kuard-amd64:blue
name: kuard-amd64
ports:
- containerPort: 8080
resources: {}
status: {}
Run
kubectl apply -f alpaca-prod.yaml
Thank you for raising this issue. We've updated this in the 3rd edition to something similar to the following
# First, create the deployment
$ kubectl create deployment alpaca-prod --image=[gcr.io/kuar-demo/kuard-amd64:blue](http://gcr.io/kuar-demo/kuard-amd64:blue) --replicas=2
# After the deployment is created, you can add some labels
$ kubectl label deployments alpaca-prod --overwrite ver=1 app=alpaca env=prod