Skip to content

Commit

Permalink
Spit deployment files for alternative build methods
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Engelhardt <[email protected]>
  • Loading branch information
antonengelhardt committed Jan 15, 2024
1 parent a182597 commit 1a21687
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 0 deletions.
90 changes: 90 additions & 0 deletions k8s/deployment-initContainer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Alternative 1: Build Plugin in a initContainer

apiVersion: apps/v1
kind: Deployment

metadata:
name: example-app
namespace: example-namespace
labels:
app: example-app

spec:

selector:
matchLabels:
app: example-envoy
replicas: 1

strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate

template:
metadata:
labels:
app: example-app

spec:
initContainers:
- name: build-plugin
image: antonengelhardt/rust-docker-tools:latest
command:
- /bin/sh
- -c
- |
apk add git
git clone https://${GITHUB_PAT}@github.com/your-org/your-repo.git #! Change URL
cd your-repo #! Change directory
cargo build --target wasm32-wasi --release
cp target/wasm32-wasi/release/name_of_your_wasm_plugin.wasm /plugins/name_of_your_wasm_plugin.wasm #! Rename, if necessary
env:
- name: GITHUB_PAT #? if your repo is private, you need to provide a github personal access token in a secret
valueFrom:
secretKeyRef:
name: github-pat
key: password

volumeMounts:
- name: plugins
mountPath: /plugins

containers:
- name: envoy
image: envoyproxy/envoy:v1.24-latest

resources:
requests:
cpu: 1000m
memory: 1000Mi
limits:
cpu: 1000m
memory: 1000Mi

volumeMounts:
- name: plugins
mountPath: /etc/envoy/proxy-wasm-plugins
- name: envoy-config
mountPath: /etc/envoy

ports:
- containerPort: 10000
name: http
protocol: TCP

command: ["envoy", "-c", "/etc/envoy/envoy.yaml", "--concurrency", "1"]

volumes:
- name: plugins
emptyDir: {}
- name: envoy-config
configMap:
name: example-envoy-config
items:
- key: envoy.yaml
path: envoy.yaml

restartPolicy: Always
62 changes: 62 additions & 0 deletions k8s/deployment-pre-built.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Alternative 2: Use pre-built [Docker-Image](https://hub.docker.com/r/antonengelhardt/wasm-oidc-plugin) from Docker Hub

apiVersion: apps/v1
kind: Deployment

metadata:
name: example-app
namespace: example-namespace
labels:
app: example-app

spec:

selector:
matchLabels:
app: example-envoy
replicas: 1

strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate

template:
metadata:
labels:
app: example-app

spec:
containers:
- name: envoy
image: antonengelhardt/wasm-oidc-plugin:latest

resources:
requests:
cpu: 1000m
memory: 1000Mi
limits:
cpu: 1000m
memory: 1000Mi

volumeMounts:
- name: envoy-config
mountPath: /etc/envoy

ports:
- containerPort: 10000
name: http
protocol: TCP

command: ["envoy", "-c", "/etc/envoy/envoy.yaml", "--concurrency", "1"]

volumes:
- name: envoy-config
configMap:
name: example-envoy-config
items:
- key: envoy.yaml
path: envoy.yaml

restartPolicy: Always

0 comments on commit 1a21687

Please sign in to comment.