mirror of
https://github.com/sablierapp/sablier.git
synced 2026-01-04 12:05:05 +01:00
docs: add kubernetes documentation (#15)
This commit is contained in:
committed by
GitHub
parent
0e920523d2
commit
1d3af8cd80
124
KUBERNETES.md
Normal file
124
KUBERNETES.md
Normal file
@@ -0,0 +1,124 @@
|
||||
# Kubernetes traefik-ondemand-service Howto
|
||||
|
||||
# Traefik parameters
|
||||
|
||||
Its important to set allowEmptyServices to true, otherwhise the scale up will
|
||||
not work because traefik cannot find the service if it was scaled down to zero.
|
||||
|
||||
- "--pilot.token=xxxx"
|
||||
- "--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"
|
||||
|
||||
If you are using the traefik helm chart its also important to set:
|
||||
|
||||
experimental:
|
||||
plugins:
|
||||
enabled: true
|
||||
|
||||
# Deployment
|
||||
|
||||
In this example we will deploy the traefik-ondemand-service into the namespace kube-system
|
||||
|
||||
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: gchr.io/acouvreur/traefik-ondemand-service
|
||||
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
|
||||
|
||||
We have to create RBAC to allow the traefik-ondemand-service to access the kubernetes API and get/update/patch the deployment resource
|
||||
|
||||
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
|
||||
|
||||
## Creating a Middleware
|
||||
|
||||
In this example we want to scale down the `code-server` deployment in the `codeserverns` namespace
|
||||
First we need to create a traefik middleware for that:
|
||||
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: ondemand-codeserver
|
||||
namespace: kube-system
|
||||
spec:
|
||||
plugin:
|
||||
traefik-ondemand-plugin:
|
||||
name: deployment_codeserverns_code-server_1
|
||||
serviceUrl: 'http://traefik-ondemand-service:10000'
|
||||
timeout: 10m
|
||||
|
||||
The delimiter in the name section is `_`. Parameters: <KIND>_<NAMESPACE>_<NAME>_<REPLICACOUNT>
|
||||
Currently only the kind deployment is supported.
|
||||
|
||||
## Using the Middleware
|
||||
|
||||
When using an Ingress (e.g. for code-server) you have to add the middleware in metadata.annotation:
|
||||
|
||||
traefik.ingress.kubernetes.io/router.middlewares: kube-system-ondemand-codeserver@kubernetescrd
|
||||
11
README.md
11
README.md
@@ -22,6 +22,7 @@
|
||||
|
||||
- Support for Docker containers
|
||||
- Support for Docker swarm mode, scale services
|
||||
- Support for Kubernetes Deployments
|
||||
- Start your container/service on the first request
|
||||
- Dynamic loading page (cloudflare or grafana cloud style)
|
||||
- Automatic scale to zero after configured timeout upon last request the service received
|
||||
@@ -30,15 +31,21 @@
|
||||
|
||||
### CLI
|
||||
|
||||
`./traefik-ondemand-service --swarmMode=true`
|
||||
`./traefik-ondemand-service --swarmMode=true --kubernetesMode=false`
|
||||
|
||||
| Argument | Value | Description |
|
||||
| ----------- | ----------------- | ----------------------------------------------------------------------- |
|
||||
| `swarmMode` | true,false (default true) | Enable/Disable swarm mode. Used to determine the scaler implementation. |
|
||||
| `kubernetesMode` | true,false (default false) | Enable/Disable Kubernetes mode. Used to determine the scaler implementation. |
|
||||
|
||||
### Docker
|
||||
|
||||
`docker run -v /var/run/docker.sock:/var/run/docker.sock -p 10000:10000 ghcr.io/acouvreur/traefik-ondemand-service:latest --swarmode=true`
|
||||
`docker run -v /var/run/docker.sock:/var/run/docker.sock -p 10000:10000
|
||||
ghcr.io/acouvreur/traefik-ondemand-service:latest --swarmode=true`
|
||||
|
||||
### Kubernetes
|
||||
|
||||
see <a href="https://github.com/acouvreur/traefik-ondemand-service/blob/main/KUBERNETES.md">KUBERNETES.md</a>
|
||||
|
||||
### API
|
||||
|
||||
|
||||
Reference in New Issue
Block a user