kinder/ci/tools/update-workflows/templates/workflows/patches-tasks.yaml [2:200]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
version: 1
summary: |
  This workflow implements a sequence of tasks for testing the patches functionality.
vars:
  # vars defines default values for variable used by tasks in this workflow;
  # those values might be overridden when importing this files.
  kubernetesVersion: v1.16.0
  baseImage: kindest/base:v20191105-ee880e9b # has containerd
  image: kindest/node:test
  clusterName: kinder-patches
  kubeadmVerbosity: 6
tasks:
  - name: pull-base-image
    description: |
      pulls kindest/base image with docker in docker and all the prerequisites necessary for running kind(er)
    cmd: docker
    args:
      - pull
      - "{{ .vars.baseImage }}"
  - name: add-kubernetes-versions
    description: |
      creates a node-image-variant by adding Kubernetes version "kubernetesVersion"
      to be used when executing "kinder do kubeadm-init"
    cmd: kinder
    args:
      - build
      - node-image-variant
      - --base-image={{ .vars.baseImage }}
      - --image={{ .vars.image }}
      - --with-init-artifacts={{ .vars.kubernetesVersion }}
      - --with-upgrade-artifacts={{ .vars.kubernetesVersion }}
      - --loglevel=debug
    timeout: 15m
  - name: create-cluster
    description: |
      create a set of nodes ready for hosting the Kubernetes cluster
    cmd: kinder
    args:
      - create
      - cluster
      - --name={{ .vars.clusterName }}
      - --image={{ .vars.image }}
      - --control-plane-nodes=2
      - --worker-nodes=1
      - --loglevel=debug
    timeout: 5m
  - name: prepare patches
    cmd: /bin/sh
    args:
      - -c
      - |
        mkdir -p /tmp/kubeadm-patches

        cat <<EOF >/tmp/kubeadm-patches/kube-apiserver.yaml
        {"metadata":{"annotations":{"patched":"true"}}}
        EOF

        cat <<EOF >/tmp/kubeadm-patches/kube-controller-manager+merge.yaml
        metadata:
          annotations:
            patched: "true"
        EOF

        cat <<EOF >/tmp/kubeadm-patches/kube-scheduler0+strategic.yaml
        metadata:
          annotations:
            patched: "true"
        EOF

        cat <<EOF >/tmp/kubeadm-patches/etcd+json.json
        [{"op":"add","path":"/metadata/annotations/patched","value":"true"}]
        EOF
  - name: prepare verify-patches.sh script
    cmd: /bin/sh
    args:
      - -c
      - |
        cat <<EOF >/tmp/verify-patches.sh
        #!/usr/bin/env bash
        res=0
        for d in /etc/kubernetes/manifests/*.yaml; do
          if grep -q "patched: \"true\"" \$d ; then
              echo "\$d is patched!"
          else
              echo "ERROR: \$d is not patched"
              res=1
          fi
        done

        if [[ "\${res}" = 0 ]]; then
          echo "All verify checks passed, congrats!"
          echo ""
        else
          echo "One or more verify checks failed! See output above..."
          echo ""
          exit 1
        fi
        EOF

        chmod +x /tmp/verify-patches.sh
  - name: copy verify-patches.sh on controlplane nodes
    cmd: kinder
    args:
      - cp
      - --name={{ .vars.clusterName }}
      - /tmp/verify-patches.sh
      - "@cp*:/kinder/verify-patches.sh"
      - --loglevel=debug
  - name: init
    description: |
      Initializes the Kubernetes cluster with version "kubernetesVersion"
      by starting the bootstrap control-plane node
    cmd: kinder
    args:
      - do
      - kubeadm-init
      - --name={{ .vars.clusterName }}
      - --patches=/tmp/kubeadm-patches
      - --loglevel=debug
      - --kubeadm-verbosity={{ .vars.kubeadmVerbosity }}
    timeout: 5m
  - name: join
    description: |
      Join a node using file discovery (without authentication credentials)
    cmd: kinder
    args:
      - do
      - kubeadm-join
      - --name={{ .vars.clusterName }}
      - --patches=/tmp/kubeadm-patches
      - --loglevel=debug
      - --kubeadm-verbosity={{ .vars.kubeadmVerbosity }}
    timeout: 10m
  - name: run verify-patches.sh on controlplane nodes before upgrades
    cmd: kinder
    args:
      - exec
      - --name={{ .vars.clusterName }}
      - "@cp*"
      - /kinder/verify-patches.sh
      - --loglevel=debug
  - name: upgrade
    description: |
      upgrades the cluster to Kubernetes "upgradeVersion"
    cmd: kinder
    args:
      - do
      - kubeadm-upgrade
      - --upgrade-version={{ .vars.kubernetesVersion }}
      - --patches=/tmp/kubeadm-patches
      - --name={{ .vars.clusterName }}
      - --loglevel=debug
      - --kubeadm-verbosity={{ .vars.kubeadmVerbosity }}
    timeout: 15m
  - name: run verify-patches.sh on controlplane nodes after upgrades
    cmd: kinder
    args:
      - exec
      - --name={{ .vars.clusterName }}
      - "@cp*"
      - /kinder/verify-patches.sh
      - --loglevel=debug
  - name: get-logs
    description: |
      Collects all the test logs
    cmd: kinder
    args:
      - export
      - logs
      - --loglevel=debug
      - --name={{ .vars.clusterName }}
      - "{{ .env.ARTIFACTS }}"
    force: true
    timeout: 5m
    # kind export log is know to be flaky, so we are temporary ignoring errors in order
    # to make the test pass in case everything else passed
    # see https://github.com/kubernetes-sigs/kind/issues/456
    ignoreError: true
  - name: reset
    description: |
      Exec kubeadm reset
    cmd: kinder
    args:
      - do
      - kubeadm-reset
      - --name={{ .vars.clusterName }}
      - --loglevel=debug
      - --kubeadm-verbosity={{ .vars.kubeadmVerbosity }}
    force: true
  - name: delete
    description: |
      Deletes the cluster
    cmd: kinder
    args:
      - delete
      - cluster
      - --name={{ .vars.clusterName }}
      - --loglevel=debug
    force: true
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



kinder/ci/workflows/patches-tasks.yaml [3:201]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
version: 1
summary: |
  This workflow implements a sequence of tasks for testing the patches functionality.
vars:
  # vars defines default values for variable used by tasks in this workflow;
  # those values might be overridden when importing this files.
  kubernetesVersion: v1.16.0
  baseImage: kindest/base:v20191105-ee880e9b # has containerd
  image: kindest/node:test
  clusterName: kinder-patches
  kubeadmVerbosity: 6
tasks:
  - name: pull-base-image
    description: |
      pulls kindest/base image with docker in docker and all the prerequisites necessary for running kind(er)
    cmd: docker
    args:
      - pull
      - "{{ .vars.baseImage }}"
  - name: add-kubernetes-versions
    description: |
      creates a node-image-variant by adding Kubernetes version "kubernetesVersion"
      to be used when executing "kinder do kubeadm-init"
    cmd: kinder
    args:
      - build
      - node-image-variant
      - --base-image={{ .vars.baseImage }}
      - --image={{ .vars.image }}
      - --with-init-artifacts={{ .vars.kubernetesVersion }}
      - --with-upgrade-artifacts={{ .vars.kubernetesVersion }}
      - --loglevel=debug
    timeout: 15m
  - name: create-cluster
    description: |
      create a set of nodes ready for hosting the Kubernetes cluster
    cmd: kinder
    args:
      - create
      - cluster
      - --name={{ .vars.clusterName }}
      - --image={{ .vars.image }}
      - --control-plane-nodes=2
      - --worker-nodes=1
      - --loglevel=debug
    timeout: 5m
  - name: prepare patches
    cmd: /bin/sh
    args:
      - -c
      - |
        mkdir -p /tmp/kubeadm-patches

        cat <<EOF >/tmp/kubeadm-patches/kube-apiserver.yaml
        {"metadata":{"annotations":{"patched":"true"}}}
        EOF

        cat <<EOF >/tmp/kubeadm-patches/kube-controller-manager+merge.yaml
        metadata:
          annotations:
            patched: "true"
        EOF

        cat <<EOF >/tmp/kubeadm-patches/kube-scheduler0+strategic.yaml
        metadata:
          annotations:
            patched: "true"
        EOF

        cat <<EOF >/tmp/kubeadm-patches/etcd+json.json
        [{"op":"add","path":"/metadata/annotations/patched","value":"true"}]
        EOF
  - name: prepare verify-patches.sh script
    cmd: /bin/sh
    args:
      - -c
      - |
        cat <<EOF >/tmp/verify-patches.sh
        #!/usr/bin/env bash
        res=0
        for d in /etc/kubernetes/manifests/*.yaml; do
          if grep -q "patched: \"true\"" \$d ; then
              echo "\$d is patched!"
          else
              echo "ERROR: \$d is not patched"
              res=1
          fi
        done

        if [[ "\${res}" = 0 ]]; then
          echo "All verify checks passed, congrats!"
          echo ""
        else
          echo "One or more verify checks failed! See output above..."
          echo ""
          exit 1
        fi
        EOF

        chmod +x /tmp/verify-patches.sh
  - name: copy verify-patches.sh on controlplane nodes
    cmd: kinder
    args:
      - cp
      - --name={{ .vars.clusterName }}
      - /tmp/verify-patches.sh
      - "@cp*:/kinder/verify-patches.sh"
      - --loglevel=debug
  - name: init
    description: |
      Initializes the Kubernetes cluster with version "kubernetesVersion"
      by starting the bootstrap control-plane node
    cmd: kinder
    args:
      - do
      - kubeadm-init
      - --name={{ .vars.clusterName }}
      - --patches=/tmp/kubeadm-patches
      - --loglevel=debug
      - --kubeadm-verbosity={{ .vars.kubeadmVerbosity }}
    timeout: 5m
  - name: join
    description: |
      Join a node using file discovery (without authentication credentials)
    cmd: kinder
    args:
      - do
      - kubeadm-join
      - --name={{ .vars.clusterName }}
      - --patches=/tmp/kubeadm-patches
      - --loglevel=debug
      - --kubeadm-verbosity={{ .vars.kubeadmVerbosity }}
    timeout: 10m
  - name: run verify-patches.sh on controlplane nodes before upgrades
    cmd: kinder
    args:
      - exec
      - --name={{ .vars.clusterName }}
      - "@cp*"
      - /kinder/verify-patches.sh
      - --loglevel=debug
  - name: upgrade
    description: |
      upgrades the cluster to Kubernetes "upgradeVersion"
    cmd: kinder
    args:
      - do
      - kubeadm-upgrade
      - --upgrade-version={{ .vars.kubernetesVersion }}
      - --patches=/tmp/kubeadm-patches
      - --name={{ .vars.clusterName }}
      - --loglevel=debug
      - --kubeadm-verbosity={{ .vars.kubeadmVerbosity }}
    timeout: 15m
  - name: run verify-patches.sh on controlplane nodes after upgrades
    cmd: kinder
    args:
      - exec
      - --name={{ .vars.clusterName }}
      - "@cp*"
      - /kinder/verify-patches.sh
      - --loglevel=debug
  - name: get-logs
    description: |
      Collects all the test logs
    cmd: kinder
    args:
      - export
      - logs
      - --loglevel=debug
      - --name={{ .vars.clusterName }}
      - "{{ .env.ARTIFACTS }}"
    force: true
    timeout: 5m
    # kind export log is know to be flaky, so we are temporary ignoring errors in order
    # to make the test pass in case everything else passed
    # see https://github.com/kubernetes-sigs/kind/issues/456
    ignoreError: true
  - name: reset
    description: |
      Exec kubeadm reset
    cmd: kinder
    args:
      - do
      - kubeadm-reset
      - --name={{ .vars.clusterName }}
      - --loglevel=debug
      - --kubeadm-verbosity={{ .vars.kubeadmVerbosity }}
    force: true
  - name: delete
    description: |
      Deletes the cluster
    cmd: kinder
    args:
      - delete
      - cluster
      - --name={{ .vars.clusterName }}
      - --loglevel=debug
    force: true
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



