Skip to content

Commit

Permalink
chore: add kustomize project for testing param CMP locally (argoproj#…
Browse files Browse the repository at this point in the history
…11265)

Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com>

Signed-off-by: Leonardo Luz Almeida <leonardo_almeida@intuit.com>
Signed-off-by: schakrad <chakradari.sindhu@gmail.com>
  • Loading branch information
leoluz authored and schakrad committed Mar 14, 2023
1 parent f6bf033 commit ea48a51
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 0 deletions.
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
- plugin.yaml
- app.yaml

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

images:
- name: quay.io/argoproj/argocd
newName: argocd
newTag: param
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

0 comments on commit ea48a51

Please sign in to comment.