mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-28 07:56:35 +01:00
docs: add kubernetes docker-compose demo (#10)
This commit is contained in:
committed by
GitHub
parent
711f6858d2
commit
e6cbbcbe60
@@ -3,7 +3,7 @@ type: middleware
|
||||
|
||||
import: github.com/acouvreur/traefik-ondemand-plugin
|
||||
|
||||
summary: 'Start your containers/services on the first request they recieve, and shut them down after a specified duration after the last request they received. Docker classic and docker swarm compatible.'
|
||||
summary: 'Start your containers/services on the first request they recieve, and shut them down after a specified duration after the last request they received. Kubernetes, Docker classic and docker swarm compatible.'
|
||||
|
||||
testData:
|
||||
serviceUrl: http://ondemand:10000
|
||||
|
||||
@@ -58,6 +58,7 @@ The docker library that interacts with the docker deamon uses `unsafe` which mus
|
||||
- [Docker Classic](./examples/docker_classic/)
|
||||
- [Docker Swarm](./examples/docker_swarm/)
|
||||
- [Multiple Containers](./examples/multiple_containers/)
|
||||
- [Kubernetes](./examples/kubernetes/)
|
||||
|
||||
## Authors
|
||||
|
||||
|
||||
29
examples/kubernetes/README.md
Normal file
29
examples/kubernetes/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Kubernetes
|
||||
|
||||
## Run the demo
|
||||
|
||||
# you need docker-compose, kubectl and helm (v3) installed
|
||||
|
||||
1. `git clone git@github.com:acouvreur/traefik-ondemand-plugin.git`
|
||||
2. `cd traefik-ondemand-plugin/examples/kubernetes`
|
||||
3. `docker-compose up`
|
||||
4. Wait 1 minute
|
||||
5. `export KUBECONFIG=./kubeconfig.yaml`
|
||||
5. `helm repo add traefik https://helm.traefik.io/traefik`
|
||||
6. `helm repo update`
|
||||
7. Edit values.yaml and add your traefik pilot.token
|
||||
8. `helm install traefik traefik/traefik -f values.yaml --namespace kube-system `
|
||||
9. `kubectl apply -f deploy-whoami.yml`
|
||||
10. `kubectl apply -f manifests.yml`
|
||||
11. Browse to http://localhost/
|
||||
12. `kubectl get deployments -o wide`
|
||||
```
|
||||
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
|
||||
whoami 1/1 1 1 16m whoami containous/whoami app=whoami
|
||||
```
|
||||
13. After 1 minute: `kubectl get deployments -o wide`
|
||||
```
|
||||
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
|
||||
whoami 0/0 0 0 17m whoami containous/whoami app=whoami`
|
||||
```
|
||||
14. Browse to http://localhost/
|
||||
49
examples/kubernetes/deploy-whoami.yml
Normal file
49
examples/kubernetes/deploy-whoami.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: whoami
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: whoami
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: whoami
|
||||
spec:
|
||||
containers:
|
||||
- name: whoami
|
||||
image: containous/whoami
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: whoami-service
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
targetPort: 80
|
||||
port: 80
|
||||
selector:
|
||||
app: whoami
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: whoami-ingress
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: traefik
|
||||
traefik.ingress.kubernetes.io/router.middlewares: default-ondemand-whoami@kubernetescrd
|
||||
spec:
|
||||
rules:
|
||||
- host: localhost
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: whoami-service
|
||||
port:
|
||||
number: 80
|
||||
29
examples/kubernetes/docker-compose.yml
Normal file
29
examples/kubernetes/docker-compose.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
version: '3'
|
||||
services:
|
||||
server:
|
||||
image: "rancher/k3s:${K3S_VERSION:-latest}"
|
||||
command: server --no-deploy traefik
|
||||
tmpfs:
|
||||
- /run
|
||||
- /var/run
|
||||
ulimits:
|
||||
nproc: 65535
|
||||
nofile:
|
||||
soft: 65535
|
||||
hard: 65535
|
||||
privileged: true
|
||||
restart: always
|
||||
environment:
|
||||
- K3S_KUBECONFIG_OUTPUT=/output/kubeconfig.yaml
|
||||
- K3S_KUBECONFIG_MODE=666
|
||||
volumes:
|
||||
- k3s-server:/var/lib/rancher/k3s
|
||||
# This is just so that we get the kubeconfig file out
|
||||
- .:/output
|
||||
ports:
|
||||
- 6443:6443 # Kubernetes API Server
|
||||
- 80:80 # Ingress controller port 80
|
||||
- 443:443 # Ingress controller port 443
|
||||
|
||||
volumes:
|
||||
k3s-server: {}
|
||||
86
examples/kubernetes/manifests.yml
Normal file
86
examples/kubernetes/manifests.yml
Normal file
@@ -0,0 +1,86 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: traefik-ondemand-service
|
||||
namespace: kube-system
|
||||
labels:
|
||||
app: traefik-ondemand-service
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: traefik-ondemand-service
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: traefik-ondemand-service
|
||||
spec:
|
||||
serviceAccountName: traefik-ondemand-service
|
||||
serviceAccount: traefik-ondemand-service
|
||||
containers:
|
||||
- name: traefik-ondemand-service
|
||||
image: ghcr.io/acouvreur/traefik-ondemand-service:sha-1d3af8c
|
||||
args: ["--swarmMode=false", "--kubernetesMode=true"]
|
||||
ports:
|
||||
- containerPort: 10000
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: traefik-ondemand-service
|
||||
namespace: kube-system
|
||||
spec:
|
||||
selector:
|
||||
app: traefik-ondemand-service
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 10000
|
||||
targetPort: 10000
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: traefik-ondemand-service
|
||||
namespace: kube-system
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: traefik-ondemand-service
|
||||
namespace: kube-system
|
||||
rules:
|
||||
- apiGroups:
|
||||
- apps
|
||||
resources:
|
||||
- deployments
|
||||
- deployments/scale
|
||||
verbs:
|
||||
- patch
|
||||
- get
|
||||
- update
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: traefik-ondemand-service
|
||||
namespace: kube-system
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: traefik-ondemand-service
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: traefik-ondemand-service
|
||||
namespace: kube-system
|
||||
---
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: ondemand-whoami
|
||||
namespace: default
|
||||
spec:
|
||||
plugin:
|
||||
traefik-ondemand-plugin:
|
||||
name: deployment_default_whoami_1
|
||||
serviceUrl: 'http://traefik-ondemand-service:10000'
|
||||
timeout: 1m
|
||||
10
examples/kubernetes/values.yaml
Normal file
10
examples/kubernetes/values.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
# traefik helm values
|
||||
additionalArguments:
|
||||
- "--pilot.token=XXXXX_YOURTOKEN_XXXXXXXXXXXXXXXX"
|
||||
- "--experimental.plugins.traefik-ondemand-plugin.modulename=github.com/acouvreur/traefik-ondemand-plugin"
|
||||
- "--experimental.plugins.traefik-ondemand-plugin.version=v0.1.1"
|
||||
- "--providers.kubernetesingress.allowEmptyServices=true"
|
||||
|
||||
experimental:
|
||||
plugins:
|
||||
enabled: true
|
||||
Reference in New Issue
Block a user