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

Support ImagePullSecret for pulling from private registry #584

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
070be81
support for imagepullsecret
gniltaws Nov 19, 2024
f137ade
extra space from bad paste
gniltaws Nov 21, 2024
855ce27
adjusted version
gniltaws Nov 23, 2024
99e997f
create pullsecret in testing workflow
gniltaws Nov 23, 2024
b139137
add pullsecret name to values file
gniltaws Nov 23, 2024
a7789db
imagePullSecrets was in the wrong location
gniltaws Nov 23, 2024
c7ccebc
bumped version
garethahealy Nov 25, 2024
699c7d5
Merge branch 'main' into imagePullSecret
garethahealy Nov 25, 2024
ba0d782
variable no longer at end of secret creation. Hopefully, this will f…
gniltaws Nov 25, 2024
aa05e68
removed trailing spaces
gniltaws Nov 25, 2024
5683b7e
operators-installer 3.1.0
gniltaws Dec 12, 2024
13020cb
helm chart for private registry secured by htpasswd
gniltaws Dec 12, 2024
e7b9281
WIP on making & using local private registry
gniltaws Dec 12, 2024
9b8b2d1
privateRegistry chart adds Ingress for registry
gniltaws Dec 13, 2024
6010cf5
integration test uses Ingress for push/pulling to private registry
gniltaws Dec 13, 2024
5d4e609
support for imagepullsecret
gniltaws Nov 19, 2024
d5aa33e
privateRegistry is now private-registry
gniltaws Dec 13, 2024
06ba03b
update private-registry chart name in workflow
gniltaws Dec 13, 2024
1b14cbd
add port to skopeo copy
gniltaws Dec 16, 2024
d238e62
fixed spacing
gniltaws Dec 16, 2024
3234c10
stop skopeo using port 443 for private registry
gniltaws Dec 16, 2024
6aac15c
use http for skopeo copy
gniltaws Dec 17, 2024
dc1b8d3
expose port 5000
gniltaws Dec 18, 2024
1921e71
skopeo copy back to docker:// protocol
gniltaws Dec 18, 2024
fb00230
exposing port 80 in kind cluster
gniltaws Dec 18, 2024
e37c76d
adds missing newlines at end of file
gniltaws Dec 18, 2024
fb6427a
removed extra imagePullSecrets
gniltaws Dec 19, 2024
975e97c
added 'name:' key to imagePullSecrets
gniltaws Dec 20, 2024
d3fa48d
increased timeout on the argo upgrade job
gniltaws Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
registry_user: registryuser1
registry_password: registrypassword1

jobs:
install-integration-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -51,6 +55,7 @@ jobs:
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
version: ${{ env.KIND_VERSION }}
config: charts/operators-installer/_integration-tests/kind-config.yaml

# for helm charts we are testing that require installing operators
- name: Setup kind cluster - Install OLM 🧰
Expand All @@ -77,6 +82,25 @@ jobs:
controller: haproxy-ingress.github.io/controller
EOF

# for testing operators-installer image from private repository
- name: Setup private registry in kind cluster 🧰
run: |
helm upgrade --install private-registry charts/operators-installer/_integration-tests/private-registry \
--namespace registry \
--create-namespace \
--wait \
--set registryUser=${registry_user} \
--set registryPassword=${registry_password}

# copies image used to install argo into local private registry
- name: Copy image into private repository 💿
run: |
skopeo copy \
--dest-creds ${registry_user}:${registry_password} \
--dest-tls-verify=false \
docker://$(awk '$1 ~/Image:/ {print $2}' charts/operators-installer/_integration-tests/test-install-operator-0-automatic-intermediate-manual-upgrades-values.yaml) \
docker://registry.localhost/origin-cli:5000

# NOTE: can't use chart-testing because `ct` does not allow for a fixed release so you can't run two different tests that affect the same resources
- name: Run integration tests 🧪
timeout-minutes: 30
Expand All @@ -91,11 +115,20 @@ jobs:
--values charts/operators-installer/_integration-tests/test-install-operator-0-automatic-intermediate-manual-upgrades-values.yaml \
--debug --timeout 10m0s

echo "##########################################################################################################"
echo "# Create pull secret used in next step #"
echo "##########################################################################################################"
oc create secret docker-registry local-registry-pullsecret \
--namespace operators-installer-integration-test \
--docker-password="${registry_user}" \
--docker-username="${registry_password}" \
--docker-server=registry.localhost

echo "##########################################################################################################"
echo "# Upgrade argo to newer version requiring many intermediate updates along the way #"
echo "##########################################################################################################"
helm upgrade --install operators-installer-integration-test charts/operators-installer \
--namespace operators-installer-integration-test \
--wait \
--values charts/operators-installer/_integration-tests/test-install-operator-1-automatic-intermediate-manual-upgrades-values.yaml \
--debug --timeout 30m0s
--debug --timeout 35m0s
2 changes: 1 addition & 1 deletion charts/operators-installer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 3.0.2
version: 3.1.0

home: https://github.com/redhat-cop/helm-charts

Expand Down
1 change: 1 addition & 0 deletions charts/operators-installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ For all of the Subscription parameters see
| operatorGroups[].targetOwnNamespace | `false` | No | If `true` add the OperatorGroup's Namespace as a `targetNamespaces`. If `true` then OperatorGroup will only work for Operators using `OwnNamespace` or `MultiNamespace` `installModes`. If blank and no `otherTargetNamespaces` specified then OperatorGroup will be configured to allow for operators using `installModes` `AllNamespaces`.
| operatorGroups[].otherTargetNamespaces | `[]` | No | List of additional Namespaces to target. If specified OperatorGroup will only work for operators using `SingleNamespace` or `MultiNamespace` `installModes` depending on value of `targetOwnNamespace`.
| installPlanApproverAndVerifyJobsImage | `registry.redhat.io/openshift4/ose-cli:v4.10` | Yes | Image to use for the InstallPlan Approver and Verify Jobs
| installPlanApproverAndVerifyJobsImagePullSecret | `''` | No | Name of existing secret for pulling `installPlanApproverAndVerifyJobsImage` from a private registry
| approveManualInstallPlanViaHook | `true` | No | `true` to create (and clean up) manual InstallPlan approval resources as part of post-install,post-upgrade helm hook<br>`false` to create manual InstallPlan approval resources as part of normal install<br><br>The hook method is nice to not have lingering resources needed for the manual InstallPlan approval but has the downside that no CustomResources using CustomResourceDefinitions installed by the operator can be used in the same chart because the operator InstallPlan wont be approved, and therefor the operator wont be installed, until the post-install,post-upgrade phase which means you will never get to that phase because your CustomResources wont be able to apply because the Operator isn't installed.<br><br>This is is ultimately a trade off between cleaning up these resources or being able to install and configure the operator in the same helm chart that has a dependency on this helm chart.
| installRequiredPythonLibraries | `true` | No | If `true`, install the required Python libraries (openshift-client, semver==2.13.0) dynamically from the given `pythonIndexURL` and `pythonExtraIndexURL` into the `installPlanApproverAndVerifyJobsImage` at run time
| pythonIndexURL | https://pypi.org/simple/ | No | If `installRequiredPythonLibraries` is `true` then use this python index to pull required libraries
Expand Down
12 changes: 12 additions & 0 deletions charts/operators-installer/_integration-tests/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 5000
hostPort: 5000
protocol: TCP
- containerPort: 80
hostPort: 80
protocol: TCP

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apiVersion: v2
name: private-registry
version: 0.0.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: registry
namespace: registry
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: registry
strategy:
type: Recreate
template:
metadata:
labels:
app: registry
spec:
containers:
- env:
- name: REGISTRY_HTTP_ADDR
value: :5000
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
value: /var/lib/registry
- name: REGISTRY_AUTH
value: htpasswd
- name: REGISTRY_AUTH_HTPASSWD_REALM
value: Registry Realm
- name: REGISTRY_AUTH_HTPASSWD_PATH
value: /auth/htpasswd
image: registry:2
imagePullPolicy: IfNotPresent
name: registry
ports:
- containerPort: 5000
name: http
protocol: TCP
resources:
limits:
cpu: 500m
memory: 128Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/registry
name: registry
- mountPath: /auth
name: htpasswd
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- name: registry
persistentVolumeClaim:
claimName: registry
- name: htpasswd
secret:
defaultMode: 420
secretName: htpasswd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: registry
namespace: registry
spec:
rules:
- host: registry.localhost
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: registry
port:
number: 5000

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: registry
namespace: registry
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 30Gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
data:
htpasswd: {{ htpasswd .Values.registryUser .Values.registryPassword | b64enc }}
kind: Secret
metadata:
name: htpasswd
namespace: registry

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: registry
name: registry
namespace: registry
spec:
ports:
- name: http
port: 5000
protocol: TCP
targetPort: 5000
selector:
app: registry
sessionAffinity: None
type: ClusterIP
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registryUser:
registryPassword:

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
approveManualInstallPlanViaHook: true

installPlanApproverAndVerifyJobsImage: quay.io/openshift/origin-cli:4.15
# use pull secret to pull image from local private registry
installPlanApproverAndVerifyJobsImage: registry.localhost/origin-cli
installPlanApproverAndVerifyJobsImagePullSecret: local-registry-pullsecret

operatorGroups:
- name: argocd-operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ spec:
activeDeadlineSeconds: {{ .installPlanApproverActiveDeadlineSeconds }}
template:
spec:
{{- if $.Values.installPlanApproverAndVerifyJobsImagePullSecret }}
imagePullSecrets:
- name: {{ $.Values.installPlanApproverAndVerifyJobsImagePullSecret }}
{{- end }}
containers:
- name: installplan-approver
image: {{ $.Values.installPlanApproverAndVerifyJobsImage }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ spec:
activeDeadlineSeconds: {{ .installPlanVerifierActiveDeadlineSeconds }}
template:
spec:
{{- if $.Values.installPlanApproverAndVerifyJobsImagePullSecret }}
imagePullSecrets:
- name: {{ $.Values.installPlanApproverAndVerifyJobsImagePullSecret }}
{{- end }}
containers:
- name: installplan-complete-verifier
image: {{ $.Values.installPlanApproverAndVerifyJobsImage }}
Expand Down
5 changes: 5 additions & 0 deletions charts/operators-installer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ approveManualInstallPlanViaHook: true
# Image to use for the InstallPlan Approver and Verify Jobs
installPlanApproverAndVerifyJobsImage: registry.redhat.io/openshift4/ose-cli:v4.15@sha256:7ea824531b593b2ec0da05557d5cd2565c3525c51c9007f85e9510b27f38b13f

# If specified, this imagePullSecret will be used for pulling the `installPlanApproverAndVerifyJobsImage`.
# Only needed when using a custom image and pulling from a private registry.
# Accepts a single string which is the name of an existing secret. (This chart does not create or manage the secret.)
installPlanApproverAndVerifyJobsImagePullSecret:

# If `true`, install the required Python libraries (openshift-client, semver==2.13.0) dynamically
# from the given `pythonIndexURL` and `pythonExtraIndexURL` into the `installPlanApproverAndVerifyJobsImage` at run time
#
Expand Down
Loading