Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to create new operator from already existing helm charts #714

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

mpryc
Copy link
Collaborator

@mpryc mpryc commented Nov 9, 2022

The intention of this script is to easy recreate operator files and ensure new version of operator-sdk can be used with our mods.

This script expects clean output directory where the operator will be generated.

Signed-off-by: Michal Pryc mpryc@redhat.com

Testing Instructions

Ensure you have correct helm charts (from the https://github.com/mpryc/pelorus-operator/tree/master/operator/helm-charts/pelorus-operators). Once they will be clean in the pelorus repo we will use them from default location.

$ source .venv/bin/activate
$ mkdir /tmp/operator
$ mkdir /tmp/generated-operator
$ pushd /tmp/operator
$ git clone git@github.com:mpryc/pelorus-operator.git
$ popd

$ ./scripts/create_pelorus_operator -h
$ ./scripts/create_pelorus_operator -s /tmp/operator/pelorus-operator/operator/helm-charts/pelorus-operators -d /tmp/generated-operator

@redhat-cop/mdt

The intention of this script is to easy recreate operator files
and ensure new version of operator-sdk can be used with our mods.

This script expects clean output directory where the operator
will be generated.

Signed-off-by: Michal Pryc <mpryc@redhat.com>
@mpryc mpryc force-pushed the pelorus_operator_script branch from fa785f0 to 2d1128f Compare November 9, 2022 14:25
@mpryc mpryc mentioned this pull request Nov 9, 2022
@mpryc
Copy link
Collaborator Author

mpryc commented Nov 9, 2022

This script together with #696 creates pelorus operator that allows to deploy pelorus stack.

@mpryc
Copy link
Collaborator Author

mpryc commented Nov 9, 2022

/retest

@mpryc mpryc requested a review from KevinMGranger November 9, 2022 15:52
@mpryc
Copy link
Collaborator Author

mpryc commented Nov 9, 2022

/retest

@weshayutin
Copy link
Contributor

weshayutin commented Nov 16, 2022

`.venv) [whayutin@thinkdoe pelorus]$ git branch
foo
master

  • pelorus_operator_script
    (.venv) [whayutin@thinkdoe pelorus]$ mkdir /tmp/operator
    (.venv) [whayutin@thinkdoe pelorus]$ mkdir /tmp/generated-operator
    (.venv) [whayutin@thinkdoe pelorus]$ pushd /tmp/operator
    /tmp/operator ~/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus
    (.venv) [whayutin@thinkdoe operator]$ git clone git@github.com:mpryc/pelorus-operator.git
    Cloning into 'pelorus-operator'...
    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
(.venv) [whayutin@thinkdoe operator]$ git clone https://github.com/mpryc/pelorus-operator.git
Cloning into 'pelorus-operator'...
remote: Enumerating objects: 90, done.
remote: Counting objects: 100% (90/90), done.
remote: Compressing objects: 100% (54/54), done.
remote: Total 90 (delta 29), reused 88 (delta 27), pack-reused 0
Receiving objects: 100% (90/90), 17.56 KiB | 580.00 KiB/s, done.
Resolving deltas: 100% (29/29), done.
(.venv) [whayutin@thinkdoe operator]$ popd
~/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus
(.venv) [whayutin@thinkdoe pelorus]$ ls
charts chart_schema.yaml CONTRIBUTING.md ct.yaml demo docs exporters labs LICENSE lintconf.yaml Makefile mkdocs.yml mocks OWNERS pelorus-operator pyproject.toml README.md readthedocs.yaml samples scripts site _test
(.venv) [whayutin@thinkdoe pelorus]$ ./scripts/create_pelorus_operator -h

Usage: ./scripts/create_pelorus_operator [OPTION]

Startup:
  -h	print this help

Options:
  -s	path to source pelorus helm charts folder, default: /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/../charts/pelorus/
  -d	path to EMPTY destination folder, default: /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/../pelorus-operator/
  -p	path to DIR with operator patches to be applied, default: /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/pelorus-operator-patches/

(.venv) [whayutin@thinkdoe pelorus]$ ./scripts/create_pelorus_operator -s /tmp/operator/pelorus-operator/operator/helm-charts/pelorus-operators -d
./scripts/create_pelorus_operator: option requires an argument -- d

Usage: ./scripts/create_pelorus_operator [OPTION]

Startup:
  -h	print this help

Options:
  -s	path to source pelorus helm charts folder, default: /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/../charts/pelorus/
  -d	path to EMPTY destination folder, default: /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/../pelorus-operator/
  -p	path to DIR with operator patches to be applied, default: /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/pelorus-operator-patches/

(.venv) [whayutin@thinkdoe pelorus]$ ./scripts/create_pelorus_operator -s /tmp/operator/pelorus-operator/operator/helm-charts/pelorus-operators -d /tmp/generated-operator/
INFO: Source directory: /tmp/operator/pelorus-operator/operator/helm-charts/pelorus-operators
INFO: Destination directory: /tmp/generated-operator/
INFO: Patches directory: /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/pelorus-operator-patches/
INFO: operator-sdk version: "v1.25.2", commit: "b63b921837de8dd6ce480033e427ecfc5e34abcc", kubernetes version: "1.25.0", go version: "go1.19.2", GOOS: "linux", GOARCH: "amd64"
/tmp/generated-operator ~/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus
INFO: Creating operator init files
Writing kustomize manifests for you to edit...
Next: define a resource with:
$ operator-sdk create api
INFO: Creating api
Writing kustomize manifests for you to edit...
Created helm-charts/pelorus-operators
Generating RBAC rules
I1116 07:46:41.094051 30918 request.go:682] Waited for 1.049622597s due to client-side throttling, not priority and fairness, request: GET:https://api.cluster-wdh11092022b.wdh11092022b.mg.dog8code.com:6443/apis/operators.coreos.com/v1?timeout=32s
WARN[0002] The RBAC rules generated in config/rbac/role.yaml are based on the chart's default manifest. Some rules may be missing for resources that are only enabled with custom values, and some existing rules may be overly broad. Double check the rules generated in config/rbac/role.yaml to ensure they meet the operator's permission requirements.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12191 100 12191 0 0 6888 0 0:00:01 0:00:01 --:--:-- 6887
INFO: Current operator version: 0.0.40
INFO: New operator version: 0.0.41
INFO: Setting IMAGE_TAG_BASE to quay.io/migtools/pelorus-operator
~/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus
INFO: Found patches in /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/pelorus-operator-patches/.
INFO: Applying patch /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/pelorus-operator-patches//01_podman_makefile_tool.diff
patching file Makefile
Hunk #2 succeeded at 75 with fuzz 2.
Hunk #3 succeeded at 163 (offset 17 lines).
Hunk #4 succeeded at 202 (offset 17 lines).
INFO: Applying patch /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/pelorus-operator-patches//02_makefile_image_url.diff
patching file Makefile
INFO: Applying patch /home/whayutin/OPENSHIFT/git/KONVEYOR/PELORUS/upstream/pelorus/scripts/pelorus-operator-patches//03_pelorus_operators_roles.diff
patching file config/rbac/kustomization.yaml
patching file config/rbac/pelorus_manager_role.yaml
patching file config/rbac/pelorus_role_binding.yaml
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12191 100 12191 0 0 42890 0 --:--:-- --:--:-- --:--:-- 42926
INFO: Current operator version: 0.0.40
INFO: New operator version: 0.0.41
INFO: Operator crated and available at: /tmp/generated-operator/
To build and push to the quay use from the operator folder:
podman login -u=migtools+pelorus -p="$QUAY_TOKEN" quay.io
make podman-build podman-push
Log in to your cluster or export KUBECONFIG
make deploy
`

Copy link
Contributor

@weshayutin weshayutin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good man.. thanks

@openshift-ci
Copy link

openshift-ci bot commented Nov 16, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: weshayutin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2022
@mpryc mpryc merged commit 8709118 into dora-metrics:master Nov 22, 2022
KevinMGranger pushed a commit to KevinMGranger/pelorus that referenced this pull request Nov 22, 2022
…-metrics#714)

The intention of this script is to easy recreate operator files
and ensure new version of operator-sdk can be used with our mods.

This script expects clean output directory where the operator
will be generated.

Signed-off-by: Michal Pryc <mpryc@redhat.com>

Signed-off-by: Michal Pryc <mpryc@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants