sigs.k8s.io/cluster-api-provider-azure@v1.17.0/templates/test/dev/patches/control-plane-custom-builds.yaml (about)

     1  apiVersion: controlplane.cluster.x-k8s.io/v1beta1
     2  kind: KubeadmControlPlane
     3  metadata:
     4    name: "${CLUSTER_NAME}-control-plane"
     5    annotations:
     6      controlplane.cluster.x-k8s.io/skip-kube-proxy: "true"
     7  spec:
     8    kubeadmConfigSpec:
     9      verbosity: 5
    10      clusterConfiguration:
    11        kubernetesVersion: "ci/${CI_VERSION}"
    12      preKubeadmCommands:
    13      - bash -c /tmp/replace-k8s-binaries.sh
    14      postKubeadmCommands:
    15      - bash -c /tmp/replace-k8s-components.sh
    16      files:
    17      - path: /tmp/replace-k8s-binaries.sh
    18        owner: "root:root"
    19        permissions: "0744"
    20        content: |
    21          #!/bin/bash
    22  
    23          set -o nounset
    24          set -o pipefail
    25          set -o errexit
    26  
    27          systemctl stop kubelet
    28          declare -a BINARIES=("kubeadm" "kubectl" "kubelet")
    29          for BINARY in "$${BINARIES[@]}"; do
    30            echo "* installing package: $${BINARY} ${KUBE_GIT_VERSION}"
    31            curl --retry 10 --retry-delay 5 -w "response status code is %{http_code}" "https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/${AZURE_BLOB_CONTAINER_NAME}/${KUBE_GIT_VERSION}/bin/linux/amd64/$${BINARY}" --output "/usr/bin/$${BINARY}"
    32          done
    33          systemctl restart kubelet
    34  
    35          # prepull images from gcr.io/k8s-staging-ci-images and retag it to
    36          # registry.k8s.io so kubeadm can fetch correct images no matter what
    37          declare -a IMAGES=("kube-apiserver" "kube-controller-manager" "kube-proxy" "kube-scheduler")
    38          [[ $(id -u) != 0 ]] && SUDO="sudo" || SUDO=""
    39          IMAGE_REGISTRY_PREFIX=registry.k8s.io
    40          for IMAGE in "$${IMAGES[@]}"; do
    41            $${SUDO} ctr -n k8s.io images tag $$IMAGE_REGISTRY_PREFIX/$$IMAGE-amd64:"${CI_VERSION//+/_}" $$IMAGE_REGISTRY_PREFIX/$$IMAGE:"${CI_VERSION//+/_}"
    42            $${SUDO} ctr -n k8s.io images tag $$IMAGE_REGISTRY_PREFIX/$$IMAGE-amd64:"${CI_VERSION//+/_}" gcr.io/k8s-staging-ci-images/$$IMAGE:"${CI_VERSION//+/_}"
    43          done
    44  
    45          echo "kubeadm version: $(kubeadm version -o=short)"
    46          echo "kubectl version: $(kubectl version --client=true)"
    47          echo "kubelet version: $(kubelet --version)"
    48      - path: /tmp/replace-k8s-components.sh
    49        owner: "root:root"
    50        permissions: "0744"
    51        content: |
    52          #!/bin/bash
    53  
    54          set -o nounset
    55          set -o pipefail
    56          set -o errexit
    57  
    58          curl -L --retry 10 --retry-delay 5 https://github.com/mikefarah/yq/releases/download/v4.6.1/yq_linux_amd64.tar.gz --output /tmp/yq_linux_amd64.tar.gz
    59          tar -xzvf /tmp/yq_linux_amd64.tar.gz -C /tmp && mv /tmp/yq_linux_amd64 /usr/bin/yq
    60          rm /tmp/yq_linux_amd64.tar.gz
    61  
    62          export KUBECONFIG=/etc/kubernetes/admin.conf
    63          kubectl -n kube-system set image daemonset/kube-proxy kube-proxy="${REGISTRY}/kube-proxy:${KUBE_IMAGE_TAG}"
    64          systemctl stop kubelet
    65          yq e '.spec.containers[0].image = "${REGISTRY}/kube-apiserver:${KUBE_IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-apiserver.yaml
    66          yq e '.spec.containers[0].image = "${REGISTRY}/kube-controller-manager:${KUBE_IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-controller-manager.yaml
    67          yq e '.spec.containers[0].image = "${REGISTRY}/kube-scheduler:${KUBE_IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-scheduler.yaml
    68          systemctl restart kubelet
    69      - path: /etc/kubernetes/azure.json
    70        owner: "root:root"
    71        permissions: "0644"
    72        contentFrom:
    73          secret:
    74            key: control-plane-azure.json
    75            name: ${CLUSTER_NAME}-control-plane-azure-json
    76  ---
    77  apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    78  kind: AzureMachineTemplate
    79  metadata:
    80    name: ${CLUSTER_NAME}-control-plane
    81  spec:
    82    template:
    83      spec:
    84        image:
    85          # we use the latest image as a workaround there is no published marketplace image for k8s CI versions.
    86          # latest binaries and images will get replaced to the desired version by the script above.
    87          marketplace:
    88            publisher: cncf-upstream
    89            offer: capi
    90            sku: ubuntu-2204-gen1
    91            version: latest