k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/config/jobs/image-pushing/k8s-staging-sig-storage.sh (about)

     1  #!/usr/bin/env bash
     2  # Copyright 2020 The Kubernetes Authors.
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #     http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  set -o errexit
    17  
    18  readonly OUTPUT="$(dirname $0)/k8s-staging-sig-storage.yaml"
    19  
    20  # Repos for which cloud image builds are working.
    21  readonly REPOS=(
    22      kubernetes-csi/csi-driver-host-path
    23      kubernetes-csi/csi-driver-smb
    24      kubernetes-csi/csi-test
    25      kubernetes-csi/external-attacher
    26      kubernetes-csi/external-health-monitor
    27      kubernetes-csi/external-provisioner
    28      kubernetes-csi/external-resizer
    29      kubernetes-csi/external-snapshotter
    30      kubernetes-csi/livenessprobe
    31      kubernetes-csi/node-driver-registrar
    32      kubernetes-csi/csi-driver-nfs
    33      kubernetes-csi/csi-driver-iscsi
    34      kubernetes-csi/lib-volume-populator
    35      kubernetes-csi/volume-data-source-validator
    36      kubernetes-sigs/sig-storage-local-static-provisioner
    37      kubernetes-sigs/nfs-ganesha-server-and-external-provisioner
    38      kubernetes-sigs/nfs-subdir-external-provisioner
    39      kubernetes-sigs/container-object-storage-interface-controller
    40      kubernetes-sigs/container-object-storage-interface-provisioner-sidecar
    41  )
    42  
    43  # Repos which should eventually enable cloud image builds but currently
    44  # don't.
    45  readonly BROKEN_REPOS=(
    46      kubernetes-csi/csi-proxy
    47  )
    48  
    49  cat >"${OUTPUT}" <<EOF
    50  # Automatically generated by k8s-staging-sig-storage-gen.sh.
    51  
    52  postsubmits:
    53  EOF
    54  
    55  for repo in "${REPOS[@]}" "${BROKEN_REPOS[@]}"; do
    56      IFS=/ read -r org repo <<<"${repo}"
    57      cat >>"${OUTPUT}" <<EOF
    58    ${org}/${repo}:
    59      - name: post-${repo}-push-images
    60        rerun_auth_config:
    61          github_team_slugs:
    62            - org: kubernetes
    63              slug: release-managers
    64            - org: kubernetes
    65              slug: test-infra-admins
    66            - org: kubernetes
    67              slug: sig-storage-image-build-admins
    68        cluster: k8s-infra-prow-build-trusted
    69        annotations:
    70          testgrid-dashboards: sig-storage-image-build, sig-k8s-infra-gcb
    71        decorate: true
    72        decoration_config:
    73          timeout: 240m
    74          grace_period: 15m
    75        branches:
    76          # For publishing canary images.
    77          - ^master$
    78          - ^release-
    79          # For publishing tagged images. Those will only get built once, i.e.
    80          # existing images are not getting overwritten. A new tag must be set to
    81          # trigger another image build. Images are only built for tags that follow
    82          # the semver format (regex from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string).
    83          - ^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
    84        spec:
    85          serviceAccountName: gcb-builder
    86          containers:
    87            - image: gcr.io/k8s-staging-test-infra/image-builder:v20230711-e33377c2b4
    88              command:
    89                - /run.sh
    90              args:
    91                # this is the project GCB will run in, which is the same as the GCR
    92                # images are pushed to.
    93                - --project=k8s-staging-sig-storage
    94                # This is the same as above, but with -gcb appended.
    95                - --scratch-bucket=gs://k8s-staging-sig-storage-gcb
    96                - --env-passthrough=PULL_BASE_REF
    97                - .
    98  EOF
    99  done
   100  
   101  cat >>"${OUTPUT}" <<EOF
   102  
   103  # Canary images are used by some Prow jobs to ensure that the upcoming releases
   104  # of the sidecars work together. We don't promote those canary images.
   105  # To avoid getting them evicted from the staging area, we have to rebuild
   106  # them periodically. One additional benefit is that build errors show up
   107  # in the sig-storage-image-build *before* tagging a release.
   108  #
   109  # Periodic jobs are currently only specified for the "master" branch
   110  # which produces the "canary" images. While other branches
   111  # could produce release-x.y-canary images, we don't use those.
   112  periodics:
   113  EOF
   114  
   115  for repo in "${REPOS[@]}"; do
   116      IFS=/ read -r org repo <<<"${repo}"
   117  cat >>"${OUTPUT}" <<EOF
   118    - name: canary-${repo}-push-images
   119      cluster: k8s-infra-prow-build-trusted
   120      annotations:
   121        testgrid-dashboards: sig-storage-image-build, sig-k8s-infra-gcb
   122      decorate: true
   123      interval: 168h # one week
   124      extra_refs:
   125        # This also becomes the current directory for run.sh and thus
   126        # the cloud image build.
   127        - org: ${org}
   128          repo: ${repo}
   129          base_ref: master
   130      spec:
   131        serviceAccountName: gcb-builder
   132        containers:
   133          - image: gcr.io/k8s-staging-test-infra/image-builder:v20230711-e33377c2b4
   134            command:
   135              - /run.sh
   136            env:
   137              # We need to emulate a pull job for the cloud build to work the same
   138              # way as it usually does.
   139              - name: PULL_BASE_REF
   140                value: master
   141            args:
   142              # this is the project GCB will run in, which is the same as the GCR
   143              # images are pushed to.
   144              - --project=k8s-staging-sig-storage
   145              # This is the same as above, but with -gcb appended.
   146              - --scratch-bucket=gs://k8s-staging-sig-storage-gcb
   147              - --env-passthrough=PULL_BASE_REF
   148              - .
   149  EOF
   150  done