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

chore: add kustomize project for testing param CMP locally #11265

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/manifests/cmp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This folder contains an Argo CD configuration file to allow
testing CMP plugins locally. The Kustomize project will:

- Install Argo CD in the current k8s context
- Patch repo server configuring a test CMP plugin
- Install an application that can be used to interact with the CMP plugin

To install Argo CD with this Kustomize project run the following
command:

`kustomize build ./test/manifests/cmp | sed 's/imagePullPolicy: Always/imagePullPolicy: Never/g' | kubectl apply -f -`

In Argo CD UI login with user/pass: admin/password

An application with name `cmp-sidecar` should be available for testing.
23 changes: 23 additions & 0 deletions test/manifests/cmp/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: plugin-test-app
spec:
project: default
source:
repoURL: https://github.com/argoproj/argo-cd.git
path: test/manifests/cmp/app
plugin:
env:
- name: FOO
value: bar
- name: REV
value: test-$ARGOCD_APP_REVISION
parameters:
- name: array-param
array:
- override
- values
destination:
namespace: default
server: https://kubernetes.default.svc
4 changes: 4 additions & 0 deletions test/manifests/cmp/app/subdir/sidecar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This yaml is used mainly to trigger the CMP plugin
# for testing purposes. In real world, it should contain
# proper kubernetes manifest files.
name: sidecar-plugin
15 changes: 15 additions & 0 deletions test/manifests/cmp/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resources:
- ../../../manifests/namespace-install
- ../../../manifests/crds
- ../../../manifests/cluster-rbac
Comment on lines +2 to +4
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't this equivalent to a cluster install?

- plugin.yaml
- app.yaml

patchesStrategicMerge:
- repo-patch.yaml
- secret-patch.yaml

images:
- name: quay.io/argoproj/argocd
newName: argocd
newTag: param
leoluz marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 29 additions & 0 deletions test/manifests/cmp/plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: my-plugin-config
data:
plugin.yaml: |
apiVersion: argoproj.io/v1alpha1
kind: ConfigManagementPlugin
metadata:
name: my-plugin
spec:
version: v1.0
init:
command: [sh , -c, 'echo "params: $ARGOCD_APP_PARAMETERS"']
generate:
command: [jq, -n, '{"kind": "ConfigMap", "apiVersion": "v1", "metadata": { "name": env.ARGOCD_APP_NAME, "namespace": env.ARGOCD_APP_NAMESPACE, "annotations": {"test": "annotation test", "KubeVersion": env.KUBE_VERSION }}, "data": { "params": env.ARGOCD_APP_PARAMETERS } }']
discover:
fileName: "./subdir/s*.yaml"
parameters:
static:
- name: string-param
string: default-string-value
- name: array-param
array: [default, items]
collectionType: array
- name: map-param
map:
some: value
collectionType: map
40 changes: 40 additions & 0 deletions test/manifests/cmp/repo-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: argocd-repo-server
app.kubernetes.io/part-of: argocd
app.kubernetes.io/component: repo-server
name: argocd-repo-server
spec:
selector:
matchLabels:
app.kubernetes.io/name: argocd-repo-server
template:
metadata:
labels:
app.kubernetes.io/name: argocd-repo-server
spec:
serviceAccountName: argocd-repo-server
automountServiceAccountToken: false
containers:
- name: my-plugin
command: [/var/run/argocd/argocd-cmp-server]
image: stedolan/jq
securityContext:
runAsNonRoot: true
runAsUser: 999
volumeMounts:
- mountPath: /var/run/argocd
name: var-files
- mountPath: /home/argocd/cmp-server/plugins
name: plugins
- mountPath: /home/argocd/cmp-server/config/plugin.yaml
subPath: plugin.yaml
name: my-plugin-config
volumes:
- configMap:
name: my-plugin-config
name: my-plugin-config
- emptyDir: {}
name: cmp-tmp
13 changes: 13 additions & 0 deletions test/manifests/cmp/secret-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: Secret
metadata:
name: argocd-secret
labels:
app.kubernetes.io/name: argocd-secret
app.kubernetes.io/part-of: argocd
stringData:
# admin.password is "password"
admin.password: $2a$10$RncPyHW/B5ll2Z3J8s.IBOnbZ9uoJ4JhHLKzj5lzG/kU1KN1Oj3/K
admin.passwordMtime: 2019-03-20T17:54:53Z
type: Opaque