Start with a simple deployment:
kubectl run simple --image=quay.io/dcooley/simple-app:plain --replicas=3 --port=80 --labels=app=simple
show the yaml for this deployment:
$ kubectl get deployment simple -o yaml --export
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
creationTimestamp: null
generation: 1
labels:
app: simple
name: simple
selfLink: /apis/extensions/v1beta1/namespaces/default/deployments/simple
spec:
replicas: 3
selector:
matchLabels:
app: simple
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: simple
spec:
containers:
- image: quay.io/dcooley/simple-app:plain
imagePullPolicy: IfNotPresent
name: simple
ports:
- containerPort: 80
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status: {}
Show the pods with the labels:
$ kubectl get pods -l app=simple --show-labels
NAME READY STATUS RESTARTS AGE LABELS
simple-1632802685-b3fff 1/1 Running 0 1m app=simple,pod-template-hash=1632802685
simple-1632802685-cdns1 1/1 Running 0 1m app=simple,pod-template-hash=1632802685
simple-1632802685-p2h3q 1/1 Running 0 1m app=simple,pod-template-hash=1632802685
Make the patch:
$ kubectl patch deployment simple --type=json -p='[{"op": "add", "path": "/spec/template/metadata/labels/this", "value": "that"}]'
deployment "simple" patched
Show that the pods have the new label:
$ kubectl get pods -l app=simple --show-labels
NAME READY STATUS RESTARTS AGE LABELS
simple-2157335326-85pzk 1/1 Running 0 25s app=simple,pod-template-hash=2157335326,this=that
simple-2157335326-g7jwv 1/1 Running 0 27s app=simple,pod-template-hash=2157335326,this=that
simple-2157335326-qmcjk 1/1 Running 0 27s app=simple,pod-template-hash=2157335326,this=that
Show the new deployment:
$ kubectl get deployment simple -o yaml --export
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2"
creationTimestamp: null
generation: 1
labels:
app: simple
name: simple
selfLink: /apis/extensions/v1beta1/namespaces/default/deployments/simple
spec:
replicas: 3
selector:
matchLabels:
app: simple
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: simple
this: that
spec:
containers:
- image: quay.io/dcooley/simple-app:plain
imagePullPolicy: IfNotPresent
name: simple
ports:
- containerPort: 80
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status: {}
Hi, Is there a way to patch the daemonset by updating the created timestamp with todays data?