From 0583b2f90bcb40f06c804711e1e7455c4a283dcd Mon Sep 17 00:00:00 2001 From: Morgan Creekmore Date: Mon, 16 Oct 2023 17:08:13 -0500 Subject: [PATCH] Add docs for testing argo rollouts, add example manifests for argo rollouts --- docs/testing-argo-rollouts.md | 41 +++++++++++++++ .../argo-rollouts/base/dotnet-core.yaml | 33 ++++++++++++ .../argo-rollouts/base/minimal-setup.yaml | 52 +++++++++++++++++++ .../examples/argo-rollouts/kustomization.yaml | 4 ++ 4 files changed, 130 insertions(+) create mode 100644 docs/testing-argo-rollouts.md create mode 100644 manifests/examples/argo-rollouts/base/dotnet-core.yaml create mode 100644 manifests/examples/argo-rollouts/base/minimal-setup.yaml create mode 100644 manifests/examples/argo-rollouts/kustomization.yaml diff --git a/docs/testing-argo-rollouts.md b/docs/testing-argo-rollouts.md new file mode 100644 index 00000000..7c5e830f --- /dev/null +++ b/docs/testing-argo-rollouts.md @@ -0,0 +1,41 @@ +# Testing Argo Rollouts + +Follow [argo rollouts installation](https://argo-rollouts.readthedocs.io/en/stable/installation/) instructions to install the controller and kubectl plugin + +## Actually Testing + +Deploy `install-prod.yaml` from [releases](https://github.com/Contrast-Security-OSS/agent-operator/releases). + +```bash +# Install the production manifests. +kubectl apply -f install-prod.yaml + +# Wait for the cluster to converge. +watch kubectl -n contrast-agent-operator get pods + +# Check the logs for any problems. +kubectl -n contrast-agent-operator logs deployment/contrast-agent-operator -f +``` + +Then we can deploy argo rollout examples + +```bash +# Install the Argo Rollout only examples (e.g. Rollout). +kubectl apply -k ./manifests/examples/argo-rollouts + +# Promote the rollout to finish the agent injection +kubectl argo rollouts promote dotnet-core-app + +# Inspect rollout in another terminal +kubectl argo rollouts get rollout dotnet-core-app --watch +``` + +We can also force a change on the container to trigger a rollout + +```bash +# Optional: Force a change to the container to trigger a rollout +kubectl argo rollouts set image dotnet-core-app dotnet-core-app=contrast/sample-app-aspnetcore:main + +# Promote the rollout to finish +kubectl argo rollouts promote dotnet-core-app +``` diff --git a/manifests/examples/argo-rollouts/base/dotnet-core.yaml b/manifests/examples/argo-rollouts/base/dotnet-core.yaml new file mode 100644 index 00000000..7ece51df --- /dev/null +++ b/manifests/examples/argo-rollouts/base/dotnet-core.yaml @@ -0,0 +1,33 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Rollout +metadata: + name: dotnet-core-app + namespace: default + labels: + app: dotnet-core-app +spec: + replicas: 2 + strategy: + canary: + steps: + - setWeight: 20 + - pause: {} + - setWeight: 40 + - pause: {duration: 10} + revisionHistoryLimit: 1 + selector: + matchLabels: + app: dotnet-core-app + template: + metadata: + labels: + app: dotnet-core-app + annotations: + test: test + spec: + containers: + - image: contrast/sample-app-aspnetcore:latest + name: dotnet-core-app + ports: + - containerPort: 80 + name: http diff --git a/manifests/examples/argo-rollouts/base/minimal-setup.yaml b/manifests/examples/argo-rollouts/base/minimal-setup.yaml new file mode 100644 index 00000000..07f2b11d --- /dev/null +++ b/manifests/examples/argo-rollouts/base/minimal-setup.yaml @@ -0,0 +1,52 @@ +apiVersion: agents.contrastsecurity.com/v1beta1 +kind: AgentInjector +metadata: + name: example-injector-dotnet-core +spec: + enabled: true + version: latest + type: dotnet-core + selector: + images: + - "*" + labels: + - name: app + value: dotnet-core-app + connection: + name: example-agent-connection + configuration: + name: example-agent-configuration +--- +apiVersion: agents.contrastsecurity.com/v1beta1 +kind: AgentConnection +metadata: + name: example-agent-connection +spec: + url: http://localhost + apiKey: + secretName: example-agent-connection-secret + secretKey: apiKey + serviceKey: + secretName: example-agent-connection-secret + secretKey: serviceKey + userName: + secretName: example-agent-connection-secret + secretKey: userName +--- +apiVersion: v1 +kind: Secret +metadata: + name: example-agent-connection-secret +type: Opaque +stringData: + apiKey: apiKey + serviceKey: serviceKey + userName: userName +--- +apiVersion: agents.contrastsecurity.com/v1beta1 +kind: AgentConfiguration +metadata: + name: example-agent-configuration +spec: + yaml: | + enabled: true diff --git a/manifests/examples/argo-rollouts/kustomization.yaml b/manifests/examples/argo-rollouts/kustomization.yaml new file mode 100644 index 00000000..0ce9417f --- /dev/null +++ b/manifests/examples/argo-rollouts/kustomization.yaml @@ -0,0 +1,4 @@ +namespace: default +resources: + - base/dotnet-core.yaml + - base/minimal-setup.yaml