From 9f6d07febc18aeaa5ff292821d3a212c6589e966 Mon Sep 17 00:00:00 2001 From: Prudhvi Godithi Date: Fri, 26 Jan 2024 15:47:14 -0800 Subject: [PATCH] Revert code refactor Signed-off-by: Prudhvi Godithi --- .github/workflows/busybox.yaml | 30 ------- .github/workflows/prepare-release.yaml | 88 ------------------- .github/workflows/release.yaml | 29 ------ CONTRIBUTING.md | 2 +- README.md | 2 +- charts/opensearch-operator/CHANGELOG.md | 8 +- charts/opensearch-operator/README.md | 10 +-- docs/userguide/main.md | 2 +- jenkins/release.jenkinsfile | 17 ++-- opensearch-operator/Dockerfile-busybox | 2 - .../pkg/builders/cluster_test.go | 6 +- .../pkg/helpers/reconcile-helpers.go | 4 +- scripts/build-image-multi-arch.sh | 2 +- 13 files changed, 23 insertions(+), 179 deletions(-) delete mode 100644 .github/workflows/busybox.yaml delete mode 100644 .github/workflows/prepare-release.yaml delete mode 100644 opensearch-operator/Dockerfile-busybox diff --git a/.github/workflows/busybox.yaml b/.github/workflows/busybox.yaml deleted file mode 100644 index ada1a3d7..00000000 --- a/.github/workflows/busybox.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# A special manual workflow to push a busybox image into our public ecr registry. This image is used for the init helper containers -name: Push busybox image to ecr -on: workflow_dispatch - - -jobs: - release: - name: Push busybox image to ecr - runs-on: ubuntu-latest - environment: - name: k8s-operator - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Pull and Push docker image - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cd opensearch-operator - export IMG=public.ecr.aws/opsterio/busybox:1.27.2-buildx - echo $IMG - aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/opsterio - docker buildx build -f Dockerfile-busybox --platform="linux/amd64,linux/arm,linux/arm64" . -t $IMG --push - cd .. diff --git a/.github/workflows/prepare-release.yaml b/.github/workflows/prepare-release.yaml deleted file mode 100644 index f9d791d2..00000000 --- a/.github/workflows/prepare-release.yaml +++ /dev/null @@ -1,88 +0,0 @@ -name: Prepare and publish release -on: - workflow_dispatch: - inputs: - version: - description: 'Version for the release, semver, NO "v" prefix' - required: true - type: string - -jobs: - release: - name: Prepare and publish release - runs-on: ubuntu-latest - environment: - name: k8s-operator - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Setup go - uses: actions/setup-go@v3 - with: - go-version: "1.19" - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Run tests - run: | - # Run test suite to make sure we have a functional commit - cd opensearch-operator - make manifests test - cd .. - - name: Prepare helm chart - run: | - # Copy CRDs to chart to make sure they are identical - cp opensearch-operator/config/crd/bases/opensearch.opster.io_*.yaml charts/opensearch-operator/files/ - # Set versions in helm chart - sed -i -e 's/^appVersion:.*/appVersion: '$RELEASE_VERSION'/' charts/opensearch-operator/Chart.yaml - sed -i -e 's/^version:.*/version: '$RELEASE_VERSION'/' charts/opensearch-operator/Chart.yaml - sed -i -e 's/^appVersion:.*/appVersion: '$RELEASE_VERSION'/' charts/opensearch-cluster/Chart.yaml - sed -i -e 's/^version:.*/version: '$RELEASE_VERSION'/' charts/opensearch-cluster/Chart.yaml - # Commit changes - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - git add charts - if git commit -m "Prepare for release $RELEASE_VERSION"; then - git push origin main - fi - # Create tag, this will not trigger the other release pipeline - git tag v$RELEASE_VERSION - git push --tags - env: - RELEASE_VERSION: ${{ inputs.version }} - - - name: Build and Push docker image - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_VERSION: ${{ inputs.version }} - run: | - cd opensearch-operator - export IMG=public.ecr.aws/opsterio/opensearch-operator:$RELEASE_VERSION - echo $IMG - aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/opsterio - docker buildx build -t $IMG --platform="linux/amd64,linux/arm,linux/arm64" . -f Dockerfile --push - cd .. - - - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: v3.8.1 - - - name: Publish helm chart - uses: stefanprodan/helm-gh-pages@master - with: - charts_dir: charts/ - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ inputs.version }} - release_name: ${{ inputs.version }} - draft: true - prerelease: false diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 295cc77f..b859f5ac 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,35 +23,6 @@ jobs: run: | echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV - - name: Build and Push operator docker image - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cd opensearch-operator - make test - export IMG=public.ecr.aws/opensearch-project/opensearch-operator:$RELEASE_VERSION - echo $IMG - aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/opsterio - docker buildx build -t $IMG --platform="linux/amd64,linux/arm,linux/arm64" . -f Dockerfile --push - cd .. - - - name: Pull and Push operator busybox docker image - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cd opensearch-operator - export IMG=public.ecr.aws/opensearch-project/opensearch-operator-busybox:$RELEASE_VERSION - echo $IMG - aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/opsterio - docker buildx build -f Dockerfile-busybox --platform="linux/amd64,linux/arm,linux/arm64" . -t $IMG --push - cd .. - - name: Make sure helm chart has correct versions run: | sed -i -e 's/^appVersion:.*/appVersion: '$RELEASE_VERSION'/' charts/opensearch-operator/Chart.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b563ab3e..75553194 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -93,7 +93,7 @@ You may type this line on your own when writing your commit messages. However, i ## Review Process -We deeply appreciate everyone who takes the time to make a contribution. We will review all contributions as quickly as possible. As a reminder, [opening an issue](https://github.com/Opster/opensearch-k8s-operator) discussing your change before you make it is the best way to smooth the PR process. This will prevent a rejection because someone else is already working on the problem, or because the solution is incompatible with the architectural direction. +We deeply appreciate everyone who takes the time to make a contribution. We will review all contributions as quickly as possible. As a reminder, [opening an issue](https://github.com/opensearch-project/opensearch-k8s-operator) discussing your change before you make it is the best way to smooth the PR process. This will prevent a rejection because someone else is already working on the problem, or because the solution is incompatible with the architectural direction. During the PR process, expect that there will be some back-and-forth. Please try to respond to comments in a timely fashion, and if you don't wish to continue with the PR, let us know. If a PR takes too many iterations for its complexity or size, we may reject it. Additionally, if you stop responding we may close the PR as abandoned. In either case, if you feel this was done in error, please add a comment on the PR. diff --git a/README.md b/README.md index a5e81614..9b7386f7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![build](https://github.com/opster/opensearch-k8s-operator/actions/workflows/docker-build.yaml/badge.svg) ![test](https://github.com/opster/opensearch-k8s-operator/actions/workflows/testing.yaml/badge.svg) ![release](https://img.shields.io/github/v/release/opster/opensearch-k8s-operator) [![Golang Lint](https://github.com/Opster/opensearch-k8s-operator/actions/workflows/linting.yaml/badge.svg)](https://github.com/Opster/opensearch-k8s-operator/actions/workflows/linting.yaml) [![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/opensearch-operator)](https://artifacthub.io/packages/search?repo=opensearch-operator) +![build](https://github.com/opensearch-project/opensearch-k8s-operator/actions/workflows/docker-build.yaml/badge.svg) ![test](https://github.com/opensearch-project/opensearch-k8s-operator/actions/workflows/testing.yaml/badge.svg) ![release](https://img.shields.io/github/v/release/opster/opensearch-k8s-operator) [![Golang Lint](https://github.com/Opster/opensearch-k8s-operator/actions/workflows/linting.yaml/badge.svg)](https://github.com/Opster/opensearch-k8s-operator/actions/workflows/linting.yaml) [![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/opensearch-operator)](https://artifacthub.io/packages/search?repo=opensearch-operator) # OpenSearch Kubernetes Operator diff --git a/charts/opensearch-operator/CHANGELOG.md b/charts/opensearch-operator/CHANGELOG.md index a8595e26..1866ab55 100644 --- a/charts/opensearch-operator/CHANGELOG.md +++ b/charts/opensearch-operator/CHANGELOG.md @@ -55,7 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### Security -[Unreleased]: https://github.com/Opster/opensearch-k8s-operator/compare/opensearch-operator-2.0.0...HEAD -[2.0.0]: https://github.com/Opster/opensearch-k8s-operator/compare/opensearch-operator-1.0.3...opensearch-operator-2.0.0 -[1.0.3]: https://github.com/Opster/opensearch-k8s-operator/compare/opensearch-operator-1.0.2...opensearch-operator-1.0.3 -[1.0.2]: https://github.com/Opster/opensearch-k8s-operator/compare/opensearch-operator-1.0.1...opensearch-operator-1.0.2 +[Unreleased]: https://github.com/opensearch-project/opensearch-k8s-operator/compare/opensearch-operator-2.0.0...HEAD +[2.0.0]: https://github.com/opensearch-project/opensearch-k8s-operator/compare/opensearch-operator-1.0.3...opensearch-operator-2.0.0 +[1.0.3]: https://github.com/opensearch-project/opensearch-k8s-operator/compare/opensearch-operator-1.0.2...opensearch-operator-1.0.3 +[1.0.2]: https://github.com/opensearch-project/opensearch-k8s-operator/compare/opensearch-operator-1.0.1...opensearch-operator-1.0.2 diff --git a/charts/opensearch-operator/README.md b/charts/opensearch-operator/README.md index f29734ca..dc63c250 100644 --- a/charts/opensearch-operator/README.md +++ b/charts/opensearch-operator/README.md @@ -1,16 +1,16 @@ # OpenSearch-k8s-operator -The Kubernetes [OpenSearch Operator](https://github.com/Opster/opensearch-k8s-operator) is used for automating the deployment, provisioning, management, and orchestration of OpenSearch clusters and OpenSearch dashboards. +The Kubernetes [OpenSearch Operator](https://github.com/opensearch-project/opensearch-k8s-operator) is used for automating the deployment, provisioning, management, and orchestration of OpenSearch clusters and OpenSearch dashboards. ## Getting started -The Operator can be easily installed using helm on any CNCF-certified Kubernetes cluster. Please refer to the [User Guide](https://github.com/Opster/opensearch-k8s-operator/blob/main/docs/userguide/main.md) for more information. +The Operator can be easily installed using helm on any CNCF-certified Kubernetes cluster. Please refer to the [User Guide](https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/docs/userguide/main.md) for more information. ### Installation Using Helm #### Get Repo Info ``` -helm repo add opensearch-operator https://opster.github.io/opensearch-k8s-operator/ +helm repo add opensearch-operator https://opensearch-project.github.io/opensearch-k8s-operator/ helm repo update ``` #### Install Chart @@ -27,7 +27,3 @@ helm repo update helm upgrade [RELEASE_NAME] opensearch-operator/opensearch-operator ``` -## Installation Tutorial and Demo - -[![Watch the video](https://opster.com/wp-content/uploads/2022/05/Operator-Installation-Tutorial.png)](https://player.vimeo.com/video/708641527) - diff --git a/docs/userguide/main.md b/docs/userguide/main.md index 2ec4e55a..031efded 100644 --- a/docs/userguide/main.md +++ b/docs/userguide/main.md @@ -767,7 +767,7 @@ manager: ### Custom init helper -During cluster initialization the operator uses init containers as helpers. For these containers a busybox image is used ( specifically `public.ecr.aws/opsterio/busybox:1.27.2-buildx`). In case you are working in an offline environment and the cluster cannot access the registry or you want to customize the image, you can override the image used by specifying the `initHelper` image in your cluster spec: +During cluster initialization the operator uses init containers as helpers. For these containers a busybox image is used ( specifically `public.ecr.aws/opensearch-project/busybox:latest`). In case you are working in an offline environment and the cluster cannot access the registry or you want to customize the image, you can override the image used by specifying the `initHelper` image in your cluster spec: ```yaml spec: diff --git a/jenkins/release.jenkinsfile b/jenkins/release.jenkinsfile index e4b6edd1..ae00c3e6 100644 --- a/jenkins/release.jenkinsfile +++ b/jenkins/release.jenkinsfile @@ -42,7 +42,6 @@ pipeline { causeString: 'A commit was pushed on opensearch-project/opensearch-k8s-operator repository main branch causing this workflow to run', printContributedVariables: false, printPostContent: false, - regexpFilterText: '$isTag', ) } environment { @@ -51,11 +50,10 @@ pipeline { TIMER_BUILD_CAUSE = currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause') } stages { - stage('OpenSearch Operator Busybox') { + stage('OpenSearch Operator') { steps { script { def ref_final = "${GIT_REFERENCE}" - println("the ref_final was : ${ref_final}") def ref_url = "${REPO_URL}/commit/${GIT_REFERENCE}" if (env.USER_BUILD_CAUSE.equals('[]') && env.TIMER_BUILD_CAUSE.equals('[]')) { ref_final = "${ref}" @@ -78,8 +76,8 @@ pipeline { checkout scm sh("git checkout ${ref_final}") - def OPERATOR_PRODUCT = "opensearch-operator-busybox" - def OPERATOR_VERSION = "$ref_final" + def OPERATOR_PRODUCT = "opensearch-operator" + def OPERATOR_VERSION = ref_final.substring(1); echo("${OPERATOR_PRODUCT}: ${OPERATOR_VERSION}") @@ -89,15 +87,14 @@ pipeline { string(name: 'DOCKER_BUILD_GIT_REPOSITORY', value: "${REPO_URL}"), string(name: 'DOCKER_BUILD_GIT_REPOSITORY_REFERENCE', value: "${ref_final}"), string(name: 'DOCKER_BUILD_SCRIPT_WITH_COMMANDS', value: [ - 'id', - 'pwd', 'ls -l', + 'cd opensearch-operator', [ 'bash', - 'scripts/build-image-multi-arch.sh', + '../scripts/build-image-multi-arch.sh', "-v ${OPERATOR_VERSION}", "-a 'x64,arm,arm64'", - "-f opensearch-operator/Dockerfile-busybox", + "-f Dockerfile", "-p ${OPERATOR_PRODUCT}" ].join(' ') ].join(' && ')), @@ -107,7 +104,7 @@ pipeline { build job: 'docker-promotion', parameters: [ string(name: 'SOURCE_IMAGES', value: '${OPERATOR_PRODUCT}:${OPERATOR_VERSION}'), - string(name: 'RELEASE_VERSION', value: "${ref_final}"), + string(name: 'RELEASE_VERSION', value: "${OPERATOR_VERSION}"), string(name: 'DOCKER_HUB_PROMOTE', value: true), string(name: 'ECR_PROMOTE', value: true), string(name: 'TAG_LATEST', value: true) diff --git a/opensearch-operator/Dockerfile-busybox b/opensearch-operator/Dockerfile-busybox deleted file mode 100644 index 6043a208..00000000 --- a/opensearch-operator/Dockerfile-busybox +++ /dev/null @@ -1,2 +0,0 @@ -# A dummy Dockerfile to prepare a multi-arch busybox image used for the init helpers -FROM busybox:1.27.2 \ No newline at end of file diff --git a/opensearch-operator/pkg/builders/cluster_test.go b/opensearch-operator/pkg/builders/cluster_test.go index ae65e96d..d4f169b0 100644 --- a/opensearch-operator/pkg/builders/cluster_test.go +++ b/opensearch-operator/pkg/builders/cluster_test.go @@ -162,7 +162,7 @@ var _ = Describe("Builders", func() { customRepository := "mycustomrepo.cr" clusterObject.Spec.General.DefaultRepo = &customRepository result := NewSTSForNodePool("foobar", &clusterObject, opsterv1.NodePool{}, "foobar", nil, nil, nil) - Expect(result.Spec.Template.Spec.InitContainers[0].Image).To(Equal("mycustomrepo.cr/busybox:1.27.2")) + Expect(result.Spec.Template.Spec.InitContainers[0].Image).To(Equal("mycustomrepo.cr/busybox:latest")) }) It("should use InitHelper.Image as InitHelper image if configured", func() { clusterObject := ClusterDescWithVersion("2.2.1") @@ -178,7 +178,7 @@ var _ = Describe("Builders", func() { It("should use defaults when no custom image is configured for InitHelper image", func() { clusterObject := ClusterDescWithVersion("2.2.1") result := NewSTSForNodePool("foobar", &clusterObject, opsterv1.NodePool{}, "foobar", nil, nil, nil) - Expect(result.Spec.Template.Spec.InitContainers[0].Image).To(Equal("public.ecr.aws/opensearch-project/opensearch-operator-busybox:latest")) + Expect(result.Spec.Template.Spec.InitContainers[0].Image).To(Equal("docker.io/busybox:latest")) }) It("should use a custom dns name when env variable is set as cluster url", func() { customDns := "custom.domain" @@ -412,7 +412,7 @@ var _ = Describe("Builders", func() { customRepository := "mycustomrepo.cr" clusterObject.Spec.General.DefaultRepo = &customRepository result := NewBootstrapPod(&clusterObject, nil, nil) - Expect(result.Spec.InitContainers[0].Image).To(Equal("mycustomrepo.cr/busybox:1.27.2")) + Expect(result.Spec.InitContainers[0].Image).To(Equal("mycustomrepo.cr/busybox:latest")) }) It("should apply the BootstrapNodeConfig to the env variables", func() { diff --git a/opensearch-operator/pkg/helpers/reconcile-helpers.go b/opensearch-operator/pkg/helpers/reconcile-helpers.go index 41fd4292..a0bc215a 100644 --- a/opensearch-operator/pkg/helpers/reconcile-helpers.go +++ b/opensearch-operator/pkg/helpers/reconcile-helpers.go @@ -11,8 +11,8 @@ import ( ) func ResolveInitHelperImage(cr *opsterv1.OpenSearchCluster) (result opsterv1.ImageSpec) { - defaultRepo := "public.ecr.aws/opensearch-project" - defaultImage := "opensearch-operator-busybox" + defaultRepo := "docker.io" + defaultImage := "busybox" defaultVersion := "latest" // If a custom InitHelper image is specified, use it. diff --git a/scripts/build-image-multi-arch.sh b/scripts/build-image-multi-arch.sh index 389f1277..a3833830 100644 --- a/scripts/build-image-multi-arch.sh +++ b/scripts/build-image-multi-arch.sh @@ -135,4 +135,4 @@ docker ps | grep $BUILDER_NAME # Build multi-arch images PLATFORMS=`echo "${ARCHITECTURE_ARRAY[@]/#/linux/}" | sed 's/x64/amd64/g;s/ /,/g'` && echo PLATFORMS $PLATFORMS -docker buildx build --platform $PLATFORMS --build-arg VERSION=$VERSION --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` --build-arg NOTES=$NOTES -t pgodithi/opensearchproject/$PRODUCT:${VERSION} -f $DOCKERFILE . --push +docker buildx build --platform $PLATFORMS --build-arg VERSION=$VERSION --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` --build-arg NOTES=$NOTES -t opensearchstaging/$PRODUCT:${VERSION} -f $DOCKERFILE . --push