From ea8db8073abd1de13d5cbfb30919be7c3de24f04 Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Thu, 7 Apr 2022 09:33:08 -0400 Subject: [PATCH 01/10] Use latest CI image version --- .github/workflows/tests-and-docker-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-and-docker-images.yml b/.github/workflows/tests-and-docker-images.yml index bacfa1c9..0263a43e 100644 --- a/.github/workflows/tests-and-docker-images.yml +++ b/.github/workflows/tests-and-docker-images.yml @@ -23,7 +23,7 @@ jobs: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - container: ghcr.io/cscetbon/casskop-build:v1.13.0 + container: ghcr.io/cscetbon/casskop-build steps: - name: Checkout repository From 6e9b88244edd639794dbf8022e68684b1ee3e218 Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Thu, 7 Apr 2022 10:12:10 -0400 Subject: [PATCH 02/10] Add yq too --- docker/ci/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/ci/Dockerfile b/docker/ci/Dockerfile index 144887dd..e5f2fd9f 100644 --- a/docker/ci/Dockerfile +++ b/docker/ci/Dockerfile @@ -49,6 +49,7 @@ RUN curl -L https://github.com/gotestyourself/gotestsum/releases/download/v0.3.4 RUN go get -u golang.org/x/lint/golint RUN go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.2 RUN go get sigs.k8s.io/kustomize/kustomize/v3@v3.5.4 +RUN go install github.com/mikefarah/yq/v4@latest # Install kubectl cli RUN curl -o /usr/local/bin/kubectl -L https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl \ From 6b20ae358cc3e6c36ff3f110b363db8d7dd52ce1 Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Fri, 8 Apr 2022 19:07:37 -0400 Subject: [PATCH 03/10] Add missing build-arg --- .github/workflows/ci-image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-image.yml b/.github/workflows/ci-image.yml index 2b6fab89..c844ebd2 100644 --- a/.github/workflows/ci-image.yml +++ b/.github/workflows/ci-image.yml @@ -32,4 +32,5 @@ jobs: tags: | ghcr.io/cscetbon/casskop-build:latest ghcr.io/cscetbon/casskop-build:${{ github.event.inputs.alias }} + build-args: OPERATOR_SDK_VERSION=v1.13.0 push: true \ No newline at end of file From 368f730b8c248c0929af2565f5c25700df91e2d3 Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Sun, 10 Apr 2022 10:29:28 -0400 Subject: [PATCH 04/10] Fix operator-sdk download and no need to install controller-gen again --- docker/ci/Dockerfile | 2 +- shared.mk | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/ci/Dockerfile b/docker/ci/Dockerfile index e5f2fd9f..195ca24b 100644 --- a/docker/ci/Dockerfile +++ b/docker/ci/Dockerfile @@ -60,7 +60,7 @@ RUN curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | # Install Operator SDK ARG OPERATOR_SDK_VERSION -RUN curl -o /usr/local/bin/operator-sdk -L https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu \ +RUN curl -o /usr/local/bin/operator-sdk -L https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk_linux_amd64 \ && chmod +x /usr/local/bin/operator-sdk WORKDIR /go/casskop diff --git a/shared.mk b/shared.mk index a29889f7..2f991c0a 100644 --- a/shared.mk +++ b/shared.mk @@ -40,7 +40,6 @@ WORKDIR := /go/casskop .PHONY: generate generate: echo "Generate zzz-deepcopy objects" - $(MAKE) controller-gen $(MAKE) generate-k8s @rm -f */crds/* $(CONTROLLER_GEN) $(CONTROLLER_GEN_OPTIONS) From fc2cb446afd4a1548858e1fd3ee6d78cbb6b7e6c Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Sun, 10 Apr 2022 10:59:32 -0400 Subject: [PATCH 05/10] Validate operator-sdk bundle --- .github/workflows/tests-and-docker-images.yml | 5 ++--- Makefile | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests-and-docker-images.yml b/.github/workflows/tests-and-docker-images.yml index 0263a43e..35bb48ae 100644 --- a/.github/workflows/tests-and-docker-images.yml +++ b/.github/workflows/tests-and-docker-images.yml @@ -50,8 +50,7 @@ jobs: - name: Generate k8s & crds run: | - GO111MODULE=on go install github.com/mikefarah/yq/v4@latest - make generate + make bundle-validate - name: Ensure there are no missing changes run: | @@ -59,7 +58,7 @@ jobs: unit-tests: runs-on: ubuntu-latest - container: ghcr.io/cscetbon/casskop-build:v1.13.0 + container: ghcr.io/cscetbon/casskop-build steps: - name: Checkout repository diff --git a/Makefile b/Makefile index 49484483..63bc7c9a 100644 --- a/Makefile +++ b/Makefile @@ -170,8 +170,10 @@ endif bundle: generate operator-sdk generate kustomize manifests -q;\ VERSION=$$(cat ./version/version.go | grep -Po '(?<=Version =\s").*(?=")');\ - $(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $${VERSION} $(BUNDLE_METADATA_OPTS);\ - operator-sdk bundle validate ./bundle;\ + $(KUSTOMIZE) build config/crd | operator-sdk generate bundle -q --overwrite --version $${VERSION} $(BUNDLE_METADATA_OPTS) + +bundle-validate: bundle + operator-sdk bundle validate ./bundle # Build the bundle image. bundle-build: From 053313c3373831dc684073651ace768bd2014dfa Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Sun, 10 Apr 2022 11:03:57 -0400 Subject: [PATCH 06/10] Update step names --- .github/workflows/tests-and-docker-images.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests-and-docker-images.yml b/.github/workflows/tests-and-docker-images.yml index 35bb48ae..d47a0006 100644 --- a/.github/workflows/tests-and-docker-images.yml +++ b/.github/workflows/tests-and-docker-images.yml @@ -48,11 +48,11 @@ jobs: - name: Vendor dependencies run: go mod vendor - - name: Generate k8s & crds + - name: Validate operator-sdk Bundle run: | make bundle-validate - - name: Ensure there are no missing changes + - name: Ensure there are no missing CRDs changes run: | [ "$(git ls-files -m | grep -cE 'zz_generated|crds')" -eq 0 ] From 520fc2d128cdbb68c8273a02964a9c168b19b303 Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Sun, 10 Apr 2022 13:55:22 -0400 Subject: [PATCH 07/10] Remove unused tasks and code --- Makefile | 5 --- multi-casskop/Makefile | 74 ------------------------------------------ shared.mk | 4 +++ 3 files changed, 4 insertions(+), 79 deletions(-) diff --git a/Makefile b/Makefile index 63bc7c9a..63e182c9 100644 --- a/Makefile +++ b/Makefile @@ -174,8 +174,3 @@ bundle: generate bundle-validate: bundle operator-sdk bundle validate ./bundle - -# Build the bundle image. -bundle-build: - docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . - diff --git a/multi-casskop/Makefile b/multi-casskop/Makefile index 2e86b2d6..e8aa4e03 100644 --- a/multi-casskop/Makefile +++ b/multi-casskop/Makefile @@ -26,12 +26,6 @@ KUBESQUASH_REGISTRY:= KUBECONFIG ?= ~/.kube/config -MINIKUBE_CONFIG ?= ~/.minikube -MINIKUBE_CONFIG_MOUNT ?= /home/ci/.minikube - -HELM_VERSION := $(shell cat helm/multi-casskop/Chart.yaml| grep version | awk -F"version: " '{print $$2}') -HELM_TARGET_DIR ?= ../docs/helm - params: @echo "CIRCLE_BRANCH = '$(CIRCLE_BRANCH)'" @echo "CIRCLE_TAG = '$(CIRCLE_TAG)'" @@ -41,11 +35,6 @@ params: # CMDs MOCKS_CMD := go generate ./mocks - -# -# -################################################################################ - # The default action of this Makefile is to build the development docker image default: build @@ -53,12 +42,6 @@ clean: @rm -rf $(OUT_BIN) || true @rm -f apis/db/v2/zz_generated.deepcopy.go || true -helm-package: - @echo Packaging $(HELM_VERSION) - helm package helm/multi-casskop - mv multi-casskop-$(HELM_VERSION).tgz $(HELM_TARGET_DIR) - helm repo index $(HELM_TARGET_DIR)/ - # Build casskop executable file in local go env export CGO_ENABLED:=0 @@ -71,38 +54,7 @@ CRD_V1 = deploy/crds/multicluster_v1alpha1_cassandramulticluster_crd.yaml CRD = config/crd/bases/db.orange.com_multicasskops.yaml FIRST_VERSION = .spec.versions[0] -.PHONY: update-crds -update-crds: - echo Update CRD - Remove protocol and set config type to object CRD -# # We checkout v1alpha1 CRD and add it to v2 CRD as it must be known to do an upgrade - git show v1.1.5-release:./$(CRD_V1) > /tmp/$$(basename $(CRD)) - sed -e '1,/versions/d' $(CRD) >> /tmp/$$(basename $(CRD)) - cp /tmp/$$(basename $(CRD)) $(CRD) - yq -i e '$(FIRST_VERSION).storage = false' $(CRD) - cp -v config/crd/bases/* helm/*/crds/ - include ../shared.mk -include ../kube.mk - -BUILD_CMD = docker build -f multi-casskop/Dockerfile . -t $(REPOSITORY):$(VERSION) --build-arg https_proxy=$$https_proxy --build-arg http_proxy=$$http_proxy - -DOCKER_BUILD = docker run --rm -v $(MOUNTDIR):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod:delegated \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v $(shell go env GOCACHE):/root/.cache/go-build:delegated \ - --env CGO_ENABLED=$(CGO_ENABLED) --env GOOS=linux --env GOARCH=amd64 \ - --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) \ - $(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c - -docker-generate-files: - cd ../ && make docker-generate-files - cp -v ../config/crd/bases/* helm/*/crds/ - $(MAKE) docker-generate-k8s - $(DOCKER_BUILD) 'cd $(BUILD_FOLDER); $(GENERATE_CMD)' - cp config/crd/bases/* helm/*/crds/ - -docker-build-operator: - echo "Build Cassandra Operator. Using cache from "$(shell go env GOCACHE) - $(DOCKER_BUILD) '$(BUILD_CMD)' # Build the Operator and its Docker Image docker-build: docker-generate-files docker-build-operator @@ -125,7 +77,6 @@ ifdef PUSHLATEST docker tag $(REPOSITORY):$(VERSION) $(REPOSITORY):latest endif - build-local: generate @echo "Build Cassandra Operator for $(GOOS)" go build -o build/_output/bin/multi-casskop-$(GOOS) -gcflags all=-trimpath=github.com/cscetbon -asmflags all=-trimpath=github.com/cscetbon github.com/cscetbon/casskop/multi-casskop/cmd/manager @@ -186,28 +137,3 @@ release: tag image publish unit-test-with-vendor: echo TODO - -kustomize: -ifeq (, $(shell which kustomize)) - @{ \ - set -e ;\ - KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\ - cd $$KUSTOMIZE_GEN_TMP_DIR ;\ - go mod init tmp ;\ - go get sigs.k8s.io/kustomize/kustomize/v3@v3.5.4 ;\ - rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\ - } -KUSTOMIZE=$(GOBIN)/kustomize -else -KUSTOMIZE=$(shell which kustomize) -endif - -# Generate bundle manifests and metadata, then validate generated files. -bundle: manifests - operator-sdk generate kustomize manifests -q - kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) - operator-sdk bundle validate ./bundle - -# Build the bundle image. -bundle-build: - docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . diff --git a/shared.mk b/shared.mk index 2f991c0a..eeb7bb07 100644 --- a/shared.mk +++ b/shared.mk @@ -44,3 +44,7 @@ generate: @rm -f */crds/* $(CONTROLLER_GEN) $(CONTROLLER_GEN_OPTIONS) $(MAKE) update-crds + +# Build the bundle image. +bundle-build: + docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . From bd9c4856799ac37013d5dea2a8aac98735f367ac Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Sun, 10 Apr 2022 15:57:22 -0400 Subject: [PATCH 08/10] Add docker-generate back --- Makefile | 5 ++++- multi-casskop/Makefile | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 63e182c9..0159738e 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ update-crds: yq -i e '$(FIRST_VERSION).storage = false' $$crd; \ done for chart in $(ls charts); do \ - cp -v config/crd/bases/* charts/${chart}/crds/; \ + cp -v config/crd/bases/*.yaml charts/${chart}/crds/; \ done include shared.mk @@ -174,3 +174,6 @@ bundle: generate bundle-validate: bundle operator-sdk bundle validate ./bundle + +docker-generate: + docker run --rm -ti -v ${PWD}:/go/casskop ghcr.io/cscetbon/casskop-build:latest make generate diff --git a/multi-casskop/Makefile b/multi-casskop/Makefile index e8aa4e03..b8e0f28c 100644 --- a/multi-casskop/Makefile +++ b/multi-casskop/Makefile @@ -56,17 +56,17 @@ FIRST_VERSION = .spec.versions[0] include ../shared.mk -# Build the Operator and its Docker Image -docker-build: docker-generate-files docker-build-operator - # Override generate as controller-gen crashes .PHONY: generate generate: - cd .. && make generate - cp -v ../config/crd/bases/* helm/*/crds/ + $(MAKE) -C .. generate + cp -v ../config/crd/bases/*.yaml ../charts/multi-casskop/crds/ $(MAKE) generate-k8s $(GENERATE_CMD) - cp config/crd/bases/* helm/*/crds/ + cp config/crd/bases/*.yaml ../charts/multi-casskop/crds/ + +docker-generate: + docker run --rm -ti -v $PWD:/go/casskop ghcr.io/cscetbon/casskop-build:latest make -C multi-casskop generate # Build CassKop executable file in local go env .PHONY: build From bbfecc1cab4c94b885dcf0ca09800bce806cc5fb Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Mon, 11 Apr 2022 21:36:49 -0400 Subject: [PATCH 09/10] Remove unused files --- tools/configure-dind-local-storage.sh | 31 ------- tools/create_dind_cluster.sh | 31 ------- tools/e2e_test_cleanup.sh | 7 -- tools/local-provisioner.yaml | 120 -------------------------- tools/publish_helm_gcs.sh | 105 ---------------------- 5 files changed, 294 deletions(-) delete mode 100755 tools/configure-dind-local-storage.sh delete mode 100755 tools/create_dind_cluster.sh delete mode 100755 tools/e2e_test_cleanup.sh delete mode 100644 tools/local-provisioner.yaml delete mode 100755 tools/publish_helm_gcs.sh diff --git a/tools/configure-dind-local-storage.sh b/tools/configure-dind-local-storage.sh deleted file mode 100755 index 6833c089..00000000 --- a/tools/configure-dind-local-storage.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -KUBE_NODES=$(kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{" "}') -NB_PV=5 - -if [ "$1" == "create" ]; then - - kubectl apply -f tools/storageclass-local-storage.yaml - - for n in $KUBE_NODES; do - echo $n - for i in `seq -w 1 $NB_PV`; do - echo docker exec -ti $n bash -c "mkdir -p /dind/local-storage/pv$i" - docker exec -ti $n bash -c "mkdir -p /dind/local-storage/pv$i" - - docker exec -ti $n bash -c "mount -t tmpfs pv$i /dind/local-storage/pv$i" - done - done - - kubectl apply -f tools/provisioner_generated.yaml - -fi - -if [ "$1" == "delete" ]; then - for n in $KUBE_NODES; do - echo $n - for i in `seq -w 1 $NB_PV`; do - kubectl delete pv local-pv-$n-$i - done - done -fi diff --git a/tools/create_dind_cluster.sh b/tools/create_dind_cluster.sh deleted file mode 100755 index b781cd88..00000000 --- a/tools/create_dind_cluster.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -echo $https_proxy -#export DIND_PROPAGATE_HTTP_PROXY=true -export DIND_HTTP_PROXY=$http_proxy -export DIND_HTTPS_PROXY=$https_proxy -export DIND_NO_PROXY=$no_proxy - -echo "Create K8s cluster" -NUM_NODES=3 dind-cluster up - -echo "Configure local-storage" -kubectl create namespace local-provisioner -kubectl config set-context $(kubectl config current-context) --namespace=local-provisioner -tools/configure-dind-local-storage.sh create - - -echo "label nodes" -kubectl label node kube-node-1 failure-domain.beta.kubernetes.io/region="europe-west2" -kubectl label node kube-node-1 location.physical/rack="1" -kubectl label node kube-node-1 failure-domain.beta.kubernetes.io/region="europe-west2" -kubectl label node kube-node-1 location.physical/rack="2" - -echo "create cassandra namespace" -kubectl create namespace cassandra-demo -kubectl config set-context $(kubectl config current-context) --namespace=cassandra-demo - -echo "Create CRD" -kubectl apply -f config/crd/bases/db.orange.com_cassandraclusters.yaml - -echo "configure helm" -helm init diff --git a/tools/e2e_test_cleanup.sh b/tools/e2e_test_cleanup.sh deleted file mode 100755 index e6c86376..00000000 --- a/tools/e2e_test_cleanup.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -echo "Deleting test namespaces" -for x in $(kns | egrep "group|main-"); do echo $x ; k delete namespace --grace-period=0 --force $x ; done - -echo "Deleting CRD" -kubectl delete -f config/crd/bases/db.orange.com_cassandraclusters.yaml diff --git a/tools/local-provisioner.yaml b/tools/local-provisioner.yaml deleted file mode 100644 index 5f950d79..00000000 --- a/tools/local-provisioner.yaml +++ /dev/null @@ -1,120 +0,0 @@ ---- -# Source: provisioner/templates/provisioner.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: local-provisioner-config - namespace: local-provisioner -data: - storageClassMap: | - local-storage: - hostDir: /dind/local-storage/ - mountDir: /dind/local-storage/ - blockCleanerCommand: - - "/scripts/shred.sh" - - "2" - volumeMode: Filesystem - fsType: ext4 ---- -apiVersion: extensions/v1beta1 -kind: DaemonSet -metadata: - name: local-volume-provisioner - namespace: local-provisioner - labels: - app: local-volume-provisioner -spec: - selector: - matchLabels: - app: local-volume-provisioner - template: - metadata: - labels: - app: local-volume-provisioner - spec: - serviceAccountName: local-storage-admin - containers: - - image: "quay.io/external_storage/local-volume-provisioner:v2.2.0" - name: provisioner - securityContext: - privileged: true - env: - - name: MY_NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: MY_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: JOB_CONTAINER_IMAGE - value: "quay.io/external_storage/local-volume-provisioner:v2.2.0" - volumeMounts: - - mountPath: /etc/provisioner/config - name: provisioner-config - readOnly: true - - mountPath: /dev - name: provisioner-dev - - mountPath: /dind/local-storage/ - name: local-storage - mountPropagation: "HostToContainer" - volumes: - - name: provisioner-config - configMap: - name: local-provisioner-config - - name: provisioner-dev - hostPath: - path: /dev - - name: local-storage - hostPath: - path: /dind/local-storage/ - ---- -# Source: provisioner/templates/provisioner-service-account.yaml - -apiVersion: v1 -kind: ServiceAccount -metadata: - name: local-storage-admin - namespace: local-provisioner - ---- -# Source: provisioner/templates/provisioner-cluster-role-binding.yaml - -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: local-storage-provisioner-pv-binding - namespace: local-provisioner -subjects: -- kind: ServiceAccount - name: local-storage-admin - namespace: local-provisioner -roleRef: - kind: ClusterRole - name: system:persistent-volume-provisioner - apiGroup: rbac.authorization.k8s.io ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: local-storage-provisioner-node-clusterrole - namespace: local-provisioner -rules: -- apiGroups: [""] - resources: ["nodes"] - verbs: ["get"] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: local-storage-provisioner-node-binding - namespace: local-provisioner -subjects: -- kind: ServiceAccount - name: local-storage-admin - namespace: local-provisioner -roleRef: - kind: ClusterRole - name: local-storage-provisioner-node-clusterrole - apiGroup: rbac.authorization.k8s.io diff --git a/tools/publish_helm_gcs.sh b/tools/publish_helm_gcs.sh deleted file mode 100755 index 2b50b04d..00000000 --- a/tools/publish_helm_gcs.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2018 The Kubernetes Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -HELM_TARGET_DIR=$(pwd)/tmp/incubator -#readonly HELM_URL=https://storage.googleapis.com/kubernetes-helm -#readonly HELM_TARBALL=helm-v2.9.1-linux-amd64.tar.gz -readonly HELM_URL=https://get.helm.sh -readonly HELM_TARBALL=helm-v3.4.2-linux-amd64.tar.gz - -#readonly STABLE_REPO_URL=https://orange-kubernetes-charts.storage.googleapis.com/ -readonly INCUBATOR_REPO_URL=https://orange-kubernetes-charts-incubator.storage.googleapis.com/ -#readonly GCS_BUCKET_STABLE=gs://orange-kubernetes-charts -readonly GCS_BUCKET_INCUBATOR=gs://orange-kubernetes-charts-incubator - -main() { - mkdir -p tmp - setup_helm_client - authenticate - -# if ! sync_repo stable "$GCS_BUCKET_STABLE" "$STABLE_REPO_URL"; then -# log_error "Not all stable charts could be packaged and synced!" -# fi - if ! sync_repo ${HELM_TARGET_DIR} "$GCS_BUCKET_INCUBATOR" "$INCUBATOR_REPO_URL"; then - log_error "Not all incubator charts could be packaged and pushed!" - fi -} - -setup_helm_client() { - echo "Setting up Helm client..." - - curl --user-agent curl-ci-sync -sSL -o "$HELM_TARBALL" "$HELM_URL/$HELM_TARBALL" - tar xzfv "$HELM_TARBALL" -C tmp - - PATH="$(pwd)/tmp/linux-amd64/:$PATH" - - helm repo add incubator-orange "$INCUBATOR_REPO_URL" -} - -authenticate() { - echo "Authenticating with Google Cloud..." - gcloud auth activate-service-account --key-file <(base64 --decode <<< "$GCP_SA_CREDS") -} - -sync_repo() { - local target_dir="${1?Specify repo dir}" - local bucket="${2?Specify repo bucket}" - local repo_url="${3?Specify repo url}" - local index_dir="${target_dir}-index" - - echo "Syncing repo '$target_dir'..." - - mkdir -p "$target_dir" - if ! gsutil cp "$bucket/index.yaml" "$index_dir/index.yaml"; then - log_error "Exiting because unable to copy index locally. Not safe to proceed." - exit 1 - fi - - local exit_code=0 - - echo "Packaging operators ..." - if ! HELM_TARGET_DIR=${target_dir} make helm-package; then - log_error "Problem packaging operator" - exit_code=1 - fi - - if helm repo index --url "$repo_url" --merge "$index_dir/index.yaml" "$target_dir"; then - # Move updated index.yaml to index folder so we don't push the old one again - mv -f "$target_dir/index.yaml" "$index_dir/index.yaml" - - gsutil cp "$target_dir/*" "$bucket" - - # Make sure index.yaml is synced last - gsutil cp "$index_dir/index.yaml" "$bucket" - else - log_error "Exiting because unable to update index. Not safe to push update." - exit 1 - fi - - ls -l "$target_dir" - - return "$exit_code" -} - -log_error() { - printf '\e[31mERROR: %s\n\e[39m' "$1" >&2 -} - -main From c2ba268384f96cc928d403a53e8da4872eb0361b Mon Sep 17 00:00:00 2001 From: Cyril Scetbon Date: Mon, 11 Apr 2022 21:57:16 -0400 Subject: [PATCH 10/10] Remove tools folder --- tools/health/go.mod | 5 ---- tools/health/go.sum | 10 -------- tools/health/main.go | 37 --------------------------- tools/storageclass-local-storage.yaml | 6 ----- 4 files changed, 58 deletions(-) delete mode 100644 tools/health/go.mod delete mode 100644 tools/health/go.sum delete mode 100644 tools/health/main.go delete mode 100644 tools/storageclass-local-storage.yaml diff --git a/tools/health/go.mod b/tools/health/go.mod deleted file mode 100644 index cbdd42f9..00000000 --- a/tools/health/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module main.go - -go 1.12 - -require github.com/sirupsen/logrus v1.4.2 diff --git a/tools/health/go.sum b/tools/health/go.sum deleted file mode 100644 index 2377f40b..00000000 --- a/tools/health/go.sum +++ /dev/null @@ -1,10 +0,0 @@ -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/tools/health/main.go b/tools/health/main.go deleted file mode 100644 index c406f2f2..00000000 --- a/tools/health/main.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2019 Orange -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//In scratch docker container, there is no binary and we cannot stat the file -// this binary goal is to be used by the k8s healthcheck for CassKop - -package main - -import ( - "os" - - "github.com/sirupsen/logrus" -) - -func main() { - if _, err := os.Stat("/tmp/operator-sdk-ready"); err == nil { - os.Exit(0) - - } else if os.IsNotExist(err) { - logrus.Infof("error file don't exists : %v", err) - os.Exit(1) - } else { - logrus.Infof("error %v", err) - os.Exit(1) - } -} diff --git a/tools/storageclass-local-storage.yaml b/tools/storageclass-local-storage.yaml deleted file mode 100644 index fcfb1a0f..00000000 --- a/tools/storageclass-local-storage.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: StorageClass -apiVersion: storage.k8s.io/v1 -metadata: - name: local-storage -provisioner: kubernetes.io/no-provisioner -volumeBindingMode: WaitForFirstConsumer