Skip to content

Instantly share code, notes, and snippets.

@yifan-gu
Last active September 8, 2017 23:20
Show Gist options
  • Save yifan-gu/235c28ed7c06ffa7162d6ec847ad1fbe to your computer and use it in GitHub Desktop.
Save yifan-gu/235c28ed7c06ffa7162d6ec847ad1fbe to your computer and use it in GitHub Desktop.
patch test

Create a manifest

cat << EOF | kubectl create -f -
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
  labels:
    k8s-app: tectonic-test-operator
    managed-by-test-operator: "true"
  name: tectonic-test-operator
  namespace: tectonic-system
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: tectonic-test-operator
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        k8s-app: tectonic-test-operator
        tectonic-app-version-name: tectonic-cluster
        pod-anti-affinity: test-operator-01
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchLabels:
                pod-anti-affinity: test-operator-01
            topologyKey: kubernetes.io/hostname
      containers:
      - env:
        - name: CLUSTER_ID
          valueFrom:
            configMapKeyRef:
              key: clusterID
              name: tectonic-config
        image: busybox
        imagePullPolicy: IfNotPresent
        name: tectonic-test-operator
        command:
        - sleep
        - "1000"
        resources:
          limits:
            cpu: 20m
            memory: 50Mi
          requests:
            cpu: 20m
            memory: 50Mi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /etc/ssl/certs
          name: certs
      dnsPolicy: ClusterFirst
      imagePullSecrets:
      - name: coreos-pull-secret
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext:
        runAsNonRoot: true
        runAsUser: 65534
      terminationGracePeriodSeconds: 30
      volumes:
      - hostPath:
          path: /usr/share/ca-certificates
        name: certs
EOF

Patch the anti-affinity

kubectl patch deployment tectonic-test-operator -n tectonic-system -p '{"spec":{"template":{"metadata":{"labels":{"pod-anti-affinity":"test-operator-02"}},"spec":{"affinity":{"podAntiAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":[{"labelSelector":{"matchLabels":{"pod-anti-affinity":"test-operator-02"}},"topologyKey":"kubernetes.io/hostname"}]}}}}}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment