Skip to content

Commit

Permalink
add secret example
Browse files Browse the repository at this point in the history
  • Loading branch information
voigt committed Dec 5, 2023
1 parent 2d2902a commit 0c047da
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
27 changes: 27 additions & 0 deletions example-3-secrets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Spin using Secrets in Kubernetes

## Scenario

This scenario will demonstrate how to inject a Kubernetes secret into a Spin Application.

## Usage

Create a secret

```
$ kubectl create secret generic spin-password --from-literal="password=super-secret"
```

Deploy the Spin application:

```
$ kubectl apply -f deploy_spin-secret.yaml
```

Access the Spin application:

```
$ kubectl port-forward deployment/spin-secret 8000:80
```

And access `localhost:8000` in your browser.
38 changes: 38 additions & 0 deletions example-3-secrets/deploy_spin-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: spin-secret
name: spin-secret
spec:
replicas: 1
selector:
matchLabels:
app: spin-secret
template:
metadata:
labels:
app: spin-secret
spec:
runtimeClassName: wasmtime-spin
containers:
- image: ghcr.io/liquid-reply/k8s-spin/spin-redis:latest
name: spin-env-explorer
command: ["/"]
env:
- name: SPIN_VARIABLE_CONFIG_VALUE
valueFrom:
secretKeyRef:
name: spin-password
key: password
resources:
limits:
cpu: 100m
memory: 100Mi
requests:
cpu: 100m
memory: 100Mi
volumes:
- name: spin-password
secret:
secretName: spin-password

0 comments on commit 0c047da

Please sign in to comment.