-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anik Bhattacharjee <[email protected]>
- Loading branch information
Showing
8 changed files
with
215 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: manager | ||
volumeMounts: | ||
- mountPath: /etc/ssl/certs/ | ||
name: ca-certs | ||
readOnly: true | ||
volumes: | ||
- name: ca-certs | ||
configMap: | ||
name: docker-registry.operator-controller-e2e.svc | ||
defaultMode: 0644 | ||
optional: false | ||
items: | ||
- key: ca-certificates.crt | ||
path: ca-certificates.crt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: kaniko | ||
namespace: operator-controller-e2e | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: kaniko | ||
image: gcr.io/kaniko-project/executor:latest | ||
args: ["--dockerfile=/workspace/test-catalog.Dockerfile", | ||
"--context=/workspace/", | ||
"--destination=docker-registry.operator-controller-e2e.svc:5000/test-catalog:e2e"] | ||
volumeMounts: | ||
- name: certs | ||
mountPath: /etc/ssl/certs/ | ||
readOnly: true | ||
- name: dockerfile | ||
mountPath: /workspace/ | ||
- name: build-contents | ||
mountPath: /workspace/test-catalog/ | ||
restartPolicy: Never | ||
volumes: | ||
- name: dockerfile | ||
configMap: | ||
name: operator-controller-e2e.dockerfile | ||
items: | ||
- key: test-catalog.Dockerfile | ||
path: test-catalog.Dockerfile | ||
- name: build-contents | ||
configMap: | ||
name: operator-controller-e2e.build-contents | ||
- name: certs | ||
configMap: | ||
name: regcerts | ||
defaultMode: 0644 | ||
optional: false | ||
items: | ||
- key: ca-certificates.crt | ||
path: ca-certificates.crt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: operator-controller-e2e | ||
--- | ||
apiVersion: cert-manager.io/v1 | ||
kind: Issuer | ||
metadata: | ||
name: selfsigned-issuer | ||
namespace: operator-controller-e2e | ||
spec: | ||
selfSigned: {} | ||
--- | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: operator-controller-e2e-registry | ||
namespace: operator-controller-e2e | ||
spec: | ||
secretName: operator-controller-e2e-registry | ||
isCA: true | ||
dnsNames: | ||
- docker-registry.operator-controller-e2e.svc | ||
privateKey: | ||
algorithm: ECDSA | ||
size: 256 | ||
issuerRef: | ||
name: selfsigned-issuer | ||
kind: Issuer | ||
group: cert-manager.io | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: docker-registry | ||
namespace: operator-controller-e2e | ||
labels: | ||
app: registry | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: registry | ||
template: | ||
metadata: | ||
labels: | ||
app: registry | ||
spec: | ||
containers: | ||
- name: registry | ||
image: registry:2 | ||
volumeMounts: | ||
- name: certs-vol | ||
mountPath: "/certs" | ||
env: | ||
- name: REGISTRY_HTTP_TLS_CERTIFICATE | ||
value: "/certs/tls.crt" | ||
- name: REGISTRY_HTTP_TLS_KEY | ||
value: "/certs/tls.key" | ||
volumes: | ||
- name: certs-vol | ||
secret: | ||
secretName: operator-controller-e2e-registry | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: docker-registry | ||
namespace: operator-controller-e2e | ||
spec: | ||
selector: | ||
app: registry | ||
ports: | ||
- port: 5000 | ||
targetPort: 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# registry.sh will create an in-cluster image registry useful for end-to-end testing | ||
# of catalogd's unpacking process. It does a few things: | ||
# 1. Installs cert-manager for creating a self-signed certificate for the image registry | ||
# 2. Creates all the resources necessary for deploying the image registry in the operator-controller-e2e namespace | ||
# 3. Creates a ConfigMap containing the CA cert for the image registry to be used by the catalogd-controller-manager | ||
# 4. Creates a ConfigMap containing the CA cert for the image registry to be used by the kaniko pod | ||
# 5. Creates ConfigMaps containing the test catalog + Dockerfile to be mounted to the kaniko pod | ||
# 6. Waits for kaniko pod to have Phase == Succeeded, indicating the test catalog image has been built + pushed | ||
# to the test image registry | ||
# Usage: | ||
# registry.sh | ||
|
||
# Install cert-manager | ||
kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/download/v1.13.1/cert-manager.yaml" | ||
kubectl wait --for=condition=Available --namespace=cert-manager deployment/cert-manager-webhook --timeout=60s | ||
|
||
# create the image registry with all the certs | ||
kubectl apply -f test/tools/imageregistry/imgreg.yaml | ||
kubectl wait -n operator-controller-e2e --for=condition=Available deployment/docker-registry --timeout=60s | ||
|
||
# get cert value | ||
certval=$(kubectl -n operator-controller-e2e get secret/operator-controller-e2e-registry -o=jsonpath='{.data.ca\.crt}' | base64 -d | sed 's/^/ /') | ||
|
||
kubectl apply -f - << EOF | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: catalogd-system | ||
EOF | ||
# create a ConfigMap that contains the CA certs for the image registry | ||
# This one is created for the catalogd-controller-manager | ||
kubectl apply -f - << EOF | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
namespace: catalogd-system | ||
name: docker-registry.operator-controller-e2e.svc | ||
data: | ||
"ca-certificates.crt": | | ||
${certval} | ||
EOF | ||
|
||
# create a ConfigMap that contains the CA certs for the image registry | ||
# this one is created for the kaniko pod | ||
kubectl apply -f - << EOF | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
namespace: operator-controller-e2e | ||
name: regcerts | ||
data: | ||
"ca-certificates.crt": | | ||
${certval} | ||
EOF | ||
|
||
# Load the testdata onto the cluster as a configmap so it can be used with kaniko | ||
kubectl create configmap -n operator-controller-e2e --from-file=testdata/catalogs/test-catalog.Dockerfile operator-controller-e2e.dockerfile | ||
kubectl create configmap -n operator-controller-e2e --from-file=testdata/catalogs/test-catalog operator-controller-e2e.build-contents | ||
|
||
# Create the kaniko pod to build the test image and push it to the test registry. | ||
kubectl apply -f test/tools/imageregistry/imagebuilder.yaml | ||
kubectl wait --for=condition=Complete -n operator-controller-e2e jobs/kaniko --timeout=60s | ||
|
||
kubectl patch deployment catalogd-controller-manager -n catalogd-system --patch-file test/tools/imageregistry/catalogd_controller_patch.yaml | ||
kubectl rollout status deployment/catalogd-controller-manager -n catalogd-system --timeout=540s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
FROM scratch | ||
ADD test-catalog /configs | ||
|
||
# Set DC-specific label for the location of the DC root directory | ||
# in the image | ||
LABEL operators.operatorframework.io.index.configs.v1=/configs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/expected_all.json | ||
..* |