Skip to content

Commit

Permalink
Create documentation for Argo Rollouts Plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisnotashwin committed Feb 21, 2024
1 parent 8ba919f commit a76a917
Show file tree
Hide file tree
Showing 2 changed files with 225 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
---
layout: docs
page_title: Using Argo Rollouts for Canary upgrades with Consul on Kubernetes
description: >-
Configuration for Argo Rollouts Controller to enable Canary deployments for subset based routing using Rollouts to integrate with Consul Service Mesh.
---

NOTES:
**_1. Currently, the Consul Traffic Routing Rollouts Plugin only supports subset based routing._**

### Install Rollouts Using Helm (Init Container)
This is the preferred method for installing this plugin.

Add the following code to your `values.yaml` file, then install the argo-rollouts by helm:

```yaml
initContainers:
- name: copy-consul-plugin
image: <TODO Insert Release Image>
command: ["/bin/sh", "-c"]
args:
# Copy the binary from the image to the rollout container
- cp /bin/rollouts-plugin-trafficrouter-consul /plugin-bin/hashicorp
volumeMounts:
- name: consul-plugin
mountPath: /plugin-bin/hashicorp
trafficRouterPlugins:
trafficRouterPlugins: |-
- name: "hashicorp/consul"
location: "file:///plugin-bin/hashicorp/rollouts-plugin-trafficrouter-consul"
volumes:
- name: consul-plugin
emptyDir: {}
volumeMounts:
- name: consul-plugin
mountPath: /plugin-bin/hashicorp
```
```bash
helm install argo-rollouts argo/argo-rollouts -f values.yaml -n argo-rollouts
```

### Install Rollouts Using Helm (Binary)

1. Build this plugin (i.e. `make build`).
2. Mount the built plugin on to the `argo-rollouts` container
3. Add the following code to your `values.yaml` file, then install the argo-rollouts by helm:

```yaml
trafficRouterPlugins:
trafficRouterPlugins: |-
- name: "argoproj-labs/consul"
location: "file:///plugin-bin/hashicorp/rollouts-plugin-trafficrouter-consul"
volumes:
- name: consul-route-plugin
hostPath:
# The path being mounted to, change this depending on your mount path
path: /rollouts-plugin-trafficrouter-consul
type: DirectoryOrCreate
volumeMounts:
- name: consul-route-plugin
mountPath: /plugin-bin/hashicorp
```
```bash
helm install argo-rollouts argo/argo-rollouts -f values.yaml -n argo-rollouts
```

### Stand-alone installation

NOTES:
**_1. The file as follows (and the codes in it) just for illustrative purposes only, please do not use directly!_**

Steps:

1. Build this plugin.
2. Put the plugin on the path & mount onto the `argo-rollouts`container (please refer to the example YAML below to modify the deployment)
3. Create a ConfigMap to configure `argo-rollouts` with the plugin's location:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: argo-rollouts
namespace: argo-rollouts
spec:
selector:
matchLabels:
app.kubernetes.io/name: argo-rollouts
template:
spec:
# ...
volumes:
# ...
- name: consul-plugin
hostPath:
path: /plugin-bin/hashicorp/rollouts-plugin-trafficrouter-consul
type: DirectoryOrCreate
containers:
- name: argo-rollouts
# ...
volumeMounts:
- name: consul-route-plugin
mountPath: /plugin-bin/hashicorp

```
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: argo-rollouts-config
namespace: argo-rollouts
data:
trafficRouterPlugins: |-
- name: "argoproj-labs/consul"
location: "file:///plugin-bin/hashicorp/rollouts-plugin-trafficrouter-consul"
binaryData: {}
```
### Install the RBAC
After either mounting the binary or using an init container apply the RBAC using the provided `yaml/rbac.yaml`
```bash
kubectl apply -f https://github.com/raw/argoproj-labs/rollouts-plugin-trafficrouter-consul/main/yaml/rbac.yaml
```

## Usage

1. Create the Kubernetes Service that will be utilized by the service being rolled out. Additionally, configure any Service Defaults and Proxy Defaults required for the service.
```yaml
apiVersion: v1
kind: Service
metadata:
name: test-service
spec:
selector:
app: test-service
ports:
- name: http
port: 80
targetPort: 8080
```

1. Create the Service Resolver and Service Splitter CRDs for your stable and canary services.
```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceResolver
metadata:
name: test-service
spec:
subsets:
stable:
filter: Service.Meta.version == 1
canary:
filter: ""
defaultSubset: stable
```
```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceSplitter
metadata:
name: test-service
spec:
splits:
- weight: 100
serviceSubset: stable
- weight: 0
serviceSubset: canary
```

1. Configure your Argo Rollout resource
```yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: test-service
spec:
replicas: 3
selector:
matchLabels:
app: test-service
template:
metadata:
labels:
app: test-service
annotations:
consul.hashicorp.com/connect-inject: "true"
consul.hashicorp.com/service-meta-version: "1"
consul.hashicorp.com/service-tags: "v1"
spec:
containers:
- name: test-service
# Using alpine vs latest as there is a build issue with M1s. Also other tests in multiport-app reference
# alpine so standardizing this.
image: docker.mirror.hashicorp.services/hashicorp/http-echo:alpine
args:
- -text="I am v1"
- -listen=:8080
ports:
- containerPort: 8080
name: http
serviceAccountName: test-service
terminationGracePeriodSeconds: 0 # so deletion is quick
strategy:
canary:
trafficRouting:
plugins:
hashicorp/consul:
stableSubsetName: stable # subset name of the stable service
canarySubsetName: canary # subset name of the canary service
serviceName: test-service
steps:
- setWeight: 20
- pause: {}
- setWeight: 40
- pause: {duration: 10}
- setWeight: 60
- pause: {duration: 10}
- setWeight: 80
- pause: {duration: 10}
```

1. Perform the Rollout operation using the Argo Rollouts Kubectl plugin.
4 changes: 4 additions & 0 deletions website/data/docs-nav-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,10 @@
"title": "Consul Enterprise",
"path": "k8s/deployment-configurations/consul-enterprise"
},
{
"title": "Argo Rollouts Configuration",
"path": "k8s/deployment-configurations/argo-rollouts-configuration"
},
{
"title": "Multi-Cluster Federation",
"routes": [
Expand Down

0 comments on commit a76a917

Please sign in to comment.