-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Kubebuilder layout ansible tests, by Fabian #3433
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6cae304
Kubebuilder layout ansible tests, by Fabian
asmacdo 172bcfa
Update hack/tests/e2e-ansible-molecule.sh
fabianvf 7bf666d
Update for newest scaffolding
fabianvf 35757d8
Get all tests passing
fabianvf e3b3419
Fix missing kustomize
fabianvf 18a8b07
operator_pull_policy -> pull_policy
fabianvf ba92493
Pull in new argstest
fabianvf 0a7b4b6
Fix rebase errors
fabianvf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -63,7 +63,7 @@ provisioner: | |
| config_dir: ${MOLECULE_PROJECT_DIRECTORY}/config | ||
| samples_dir: ${MOLECULE_PROJECT_DIRECTORY}/config/samples | ||
| operator_image: ${OPERATOR_IMAGE:-""} | ||
| operator_pull_policy: ${OPERATOR_PULL_POLICY:-"Always"} | ||
| pull_policy: ${OPERATOR_PULL_POLICY:-"Always"} | ||
| kustomize: ${KUSTOMIZE_PATH:-kustomize} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @asmacdo you will need to change here as well. https://github.com/operator-framework/operator-sdk/pull/3654/files :-) |
||
| env: | ||
| K8S_AUTH_KUBECONFIG: ${KUBECONFIG:-"~/.kube/config"} | ||
|
|
||
This file contains hidden or 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,20 @@ | ||
| FROM quay.io/operator-framework/ansible-operator:dev | ||
|
|
||
| COPY requirements.yml ${HOME}/requirements.yml | ||
| RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \ | ||
| && chmod -R ug+rwx ${HOME}/.ansible | ||
| COPY ansible.cfg /etc/ansible/ansible.cfg | ||
| COPY watches.yaml ${HOME}/watches.yaml | ||
|
|
||
| COPY roles/ ${HOME}/roles/ | ||
| COPY playbooks/ ${HOME}/playbooks/ | ||
| COPY inventory/ ${HOME}/inventory/ | ||
| COPY plugins/ ${HOME}/plugins/ | ||
| COPY fixture_collection/ /tmp/fixture_collection/ | ||
| USER root | ||
| RUN chmod -R ug+rwx /tmp/fixture_collection | ||
| USER 1001 | ||
| RUN ansible-galaxy collection build /tmp/fixture_collection/ --output-path /tmp/fixture_collection/ \ | ||
| && ansible-galaxy collection install /tmp/fixture_collection/operator_sdk-test_fixtures-0.0.0.tar.gz \ | ||
| && echo abc123 > /opt/ansible/pwd.yml \ | ||
| && ansible-vault encrypt_string --vault-password-file /opt/ansible/pwd.yml 'thisisatest' --name 'the_secret' > /opt/ansible/vars.yml |
This file contains hidden or 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,91 @@ | ||
| # Current Operator version | ||
| VERSION ?= 0.0.1 | ||
| # Default bundle image tag | ||
| BUNDLE_IMG ?= controller-bundle:$(VERSION) | ||
| # Options for 'bundle-build' | ||
| ifneq ($(origin CHANNELS), undefined) | ||
| BUNDLE_CHANNELS := --channels=$(CHANNELS) | ||
| endif | ||
| ifneq ($(origin DEFAULT_CHANNEL), undefined) | ||
| BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL) | ||
| endif | ||
| BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) | ||
|
|
||
| .PHONY: bundle | ||
|
|
||
| # Image URL to use all building/pushing image targets | ||
| IMG ?= controller:latest | ||
|
|
||
| all: docker-build | ||
|
|
||
| # Run against the configured Kubernetes cluster in ~/.kube/config | ||
| run: ansible-operator | ||
| $(ANSIBLE_OPERATOR) | ||
|
|
||
| # Install CRDs into a cluster | ||
| install: kustomize | ||
| $(KUSTOMIZE) build config/crd | kubectl apply -f - | ||
|
|
||
| # Uninstall CRDs from a cluster | ||
| uninstall: kustomize | ||
| $(KUSTOMIZE) build config/crd | kubectl delete -f - | ||
|
|
||
| # Deploy controller in the configured Kubernetes cluster in ~/.kube/config | ||
| deploy: kustomize | ||
| cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
| $(KUSTOMIZE) build config/default | kubectl apply -f - | ||
|
|
||
| # Undeploy controller in the configured Kubernetes cluster in ~/.kube/config | ||
| undeploy: kustomize | ||
| $(KUSTOMIZE) build config/default | kubectl delete -f - | ||
|
|
||
| # Build the docker image | ||
| docker-build: | ||
| docker build . -t ${IMG} | ||
|
|
||
| # Push the docker image | ||
| docker-push: | ||
| docker push ${IMG} | ||
|
|
||
| PATH := $(PATH):$(PWD)/bin | ||
| SHELL := env PATH=$(PATH) /bin/sh | ||
| OS = $(shell uname -s | tr '[:upper:]' '[:lower:]') | ||
| ARCH = $(shell uname -m | sed 's/x86_64/amd64/') | ||
| OSOPER = $(shell uname -s | tr '[:upper:]' '[:lower:]' | sed 's/darwin/apple-darwin/' | sed 's/linux/linux-gnu/') | ||
| ARCHOPER = $(shell uname -m ) | ||
|
|
||
| kustomize: | ||
| ifeq (, $(shell which kustomize 2>/dev/null)) | ||
| @{ \ | ||
| set -e ;\ | ||
| mkdir -p bin ;\ | ||
| curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.5.4/kustomize_v3.5.4_$(OS)_$(ARCH).tar.gz | tar xzf - -C bin/ ;\ | ||
| } | ||
| KUSTOMIZE=./bin/kustomize | ||
| else | ||
| KUSTOMIZE=$(shell which kustomize) | ||
| endif | ||
|
|
||
| ansible-operator: | ||
| ifeq (, $(shell which ansible-operator 2>/dev/null)) | ||
| @{ \ | ||
| set -e ;\ | ||
| mkdir -p bin ;\ | ||
| curl -LO https://github.com/operator-framework/operator-sdk/releases/download/v0.19.0/ansible-operator-v0.19.0-$(ARCHOPER)-$(OSOPER) ;\ | ||
| mv ansible-operator-v0.19.0-$(ARCHOPER)-$(OSOPER) ./bin/ansible-operator ;\ | ||
| chmod +x ./bin/ansible-operator ;\ | ||
| } | ||
| ANSIBLE_OPERATOR=$(realpath ./bin/ansible-operator) | ||
| else | ||
| ANSIBLE_OPERATOR=$(shell which ansible-operator) | ||
| endif | ||
|
camilamacedo86 marked this conversation as resolved.
|
||
|
|
||
| # Generate bundle manifests and metadata, then validate generated files. | ||
| bundle: kustomize | ||
| 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) . | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,4 @@ | ||
| domain: example.com | ||
| layout: ansible.sdk.operatorframework.io/v1 | ||
| projectName: ansible | ||
| version: 3-alpha |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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,11 @@ | ||
| # This kustomization.yaml is not intended to be run by itself, | ||
| # since it depends on service name and namespace that are out of this kustomize package. | ||
| # It should be run by config/default | ||
| resources: | ||
| - bases/test.example.com_argstest_crd.yaml | ||
| - bases/test.example.com_casetest_crd.yaml | ||
| - bases/test.example.com_collectiontests_crd.yaml | ||
| - bases/test.example.com_inventorytests_crd.yaml | ||
| - bases/test.example.com_selectortests_crd.yaml | ||
| - bases/test.example.com_subresourcestests_crd.yaml | ||
| # +kubebuilder:scaffold:crdkustomizeresource |
This file contains hidden or 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,26 @@ | ||
| # Adds namespace to all resources. | ||
| namespace: ansible-system | ||
|
|
||
| # Value of this field is prepended to the | ||
| # names of all resources, e.g. a deployment named | ||
| # "wordpress" becomes "alices-wordpress". | ||
| # Note that it should also match with the prefix (text before '-') of the namespace | ||
| # field above. | ||
| namePrefix: ansible- | ||
|
|
||
| # Labels to add to all resources and selectors. | ||
| #commonLabels: | ||
| # someName: someValue | ||
|
|
||
| bases: | ||
| - ../crd | ||
| - ../rbac | ||
| - ../manager | ||
| # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. | ||
| #- ../prometheus | ||
|
|
||
| patchesStrategicMerge: | ||
| # Protect the /metrics endpoint by putting it behind auth. | ||
| # If you want your controller-manager to expose the /metrics | ||
| # endpoint w/o any authn/z, please comment the following line. | ||
| - manager_auth_proxy_patch.yaml |
This file contains hidden or 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,21 @@ | ||
| # This patch inject a sidecar container which is a HTTP proxy for the | ||
| # controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: controller-manager | ||
| namespace: system | ||
| spec: | ||
| template: | ||
| spec: | ||
| containers: | ||
| - name: kube-rbac-proxy | ||
| image: gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0 | ||
| args: | ||
| - "--secure-listen-address=0.0.0.0:8443" | ||
| - "--upstream=http://127.0.0.1:8080/" | ||
| - "--logtostderr=true" | ||
| - "--v=10" | ||
| ports: | ||
| - containerPort: 8443 | ||
| name: https |
This file contains hidden or 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 @@ | ||
| resources: | ||
| - manager.yaml |
This file contains hidden or 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,36 @@ | ||
| apiVersion: v1 | ||
| kind: Namespace | ||
| metadata: | ||
| labels: | ||
| control-plane: controller-manager | ||
| name: system | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: controller-manager | ||
| namespace: system | ||
| labels: | ||
| control-plane: controller-manager | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| control-plane: controller-manager | ||
| replicas: 1 | ||
| template: | ||
| metadata: | ||
| labels: | ||
| control-plane: controller-manager | ||
| spec: | ||
| containers: | ||
| - name: manager | ||
| args: | ||
| - "--metrics-addr=127.0.0.1:8080" | ||
| - "--enable-leader-election" | ||
| - "--leader-election-id=ansible" | ||
| - "--ansible-args='--vault-password-file /opt/ansible/pwd.yml'" | ||
| image: controller:latest | ||
| env: | ||
| - name: ANSIBLE_INVENTORY | ||
| value: /opt/ansible/inventory | ||
| terminationGracePeriodSeconds: 10 |
This file contains hidden or 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 @@ | ||
| resources: | ||
| - monitor.yaml |
This file contains hidden or 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,16 @@ | ||
| --- | ||
| # Prometheus Monitor Service (Metrics) | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: ServiceMonitor | ||
| metadata: | ||
| labels: | ||
| control-plane: controller-manager | ||
| name: controller-manager-metrics-monitor | ||
| namespace: system | ||
| spec: | ||
| endpoints: | ||
| - path: /metrics | ||
| port: https | ||
| selector: | ||
| matchLabels: | ||
| control-plane: controller-manager |
This file contains hidden or 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,7 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: metrics-reader | ||
| rules: | ||
| - nonResourceURLs: ["/metrics"] | ||
| verbs: ["get"] |
This file contains hidden or 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,13 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: proxy-role | ||
| rules: | ||
| - apiGroups: ["authentication.k8s.io"] | ||
| resources: | ||
| - tokenreviews | ||
| verbs: ["create"] | ||
| - apiGroups: ["authorization.k8s.io"] | ||
| resources: | ||
| - subjectaccessreviews | ||
| verbs: ["create"] |
This file contains hidden or 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,12 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: proxy-rolebinding | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: proxy-role | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: default | ||
| namespace: system |
This file contains hidden or 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,14 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| labels: | ||
| control-plane: controller-manager | ||
| name: controller-manager-metrics-service | ||
| namespace: system | ||
| spec: | ||
| ports: | ||
| - name: https | ||
| port: 8443 | ||
| targetPort: https | ||
| selector: | ||
| control-plane: controller-manager |
This file contains hidden or 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,50 @@ | ||
| resources: | ||
| - role.yaml | ||
| - role_binding.yaml | ||
| - leader_election_role.yaml | ||
| - leader_election_role_binding.yaml | ||
| # Comment the following 4 lines if you want to disable | ||
| # the auth proxy (https://github.com/brancz/kube-rbac-proxy) | ||
| # which protects your /metrics endpoint. | ||
| - auth_proxy_service.yaml | ||
| - auth_proxy_role.yaml | ||
| - auth_proxy_role_binding.yaml | ||
| - auth_proxy_client_clusterrole.yaml | ||
| patchesJson6902: | ||
| - target: | ||
| group: rbac.authorization.k8s.io | ||
| version: v1 | ||
| kind: ClusterRole | ||
| name: manager-role | ||
| path: patches/collectiontests_editor_role.yaml | ||
| - target: | ||
| group: rbac.authorization.k8s.io | ||
| version: v1 | ||
| kind: ClusterRole | ||
| name: manager-role | ||
| path: patches/inventorytests_editor_role.yaml | ||
| - target: | ||
| group: rbac.authorization.k8s.io | ||
| version: v1 | ||
| kind: ClusterRole | ||
| name: manager-role | ||
| path: patches/selectortests_editor_role.yaml | ||
| - target: | ||
| group: rbac.authorization.k8s.io | ||
| version: v1 | ||
| kind: ClusterRole | ||
| name: manager-role | ||
| path: patches/subresourcestests_editor_role.yaml | ||
| - target: | ||
| group: rbac.authorization.k8s.io | ||
| version: v1 | ||
| kind: ClusterRole | ||
| name: manager-role | ||
| path: patches/casetests_editor_role.yaml | ||
| - target: | ||
| group: rbac.authorization.k8s.io | ||
| version: v1 | ||
| kind: ClusterRole | ||
| name: manager-role | ||
| path: patches/argstests_editor_role.yaml | ||
| # +kubebuilder:scaffold:patch6902 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think might have a better way.
However, IMO the goal is to ensure that we are doing the same tests with the new layout.
I understand that all these tests will be migrated to GO tests, in this way in POV has no reason to be too precious with :-)