feat: add k3s deployment and service configurations for ok-server
This commit is contained in:
@@ -96,6 +96,50 @@ container run --rm -d --name ok-server -c 1 -m 256m -p 8080:8080 ok-server
|
||||
|
||||
This will start the server and expose it on port 8080. The container will run until stopped, and will be removed when stopped. You can stop it with `container stop ok-server`.
|
||||
|
||||
### nerdctl with BuildKit on a k3s server
|
||||
|
||||
Build the image directly into the containerd instance used by k3s:
|
||||
|
||||
```bash
|
||||
sudo nerdctl build -t ok-server .
|
||||
sudo nerdctl images
|
||||
```
|
||||
|
||||
On a single-node k3s cluster the image is now available to the kubelet without a
|
||||
registry. The [k3s/deployment.yaml](k3s/deployment.yaml) Deployment references
|
||||
it with `imagePullPolicy: Never`:
|
||||
|
||||
```bash
|
||||
kubectl apply -f k3s/deployment.yaml
|
||||
```
|
||||
|
||||
Expose the app with one of the two options below.
|
||||
|
||||
#### Option 1: Traefik Ingress
|
||||
|
||||
k3s includes the Traefik ingress controller. The ClusterIP Service and Ingress
|
||||
in [k3s/expose-ingress.yaml](k3s/expose-ingress.yaml) expose the app on port 80
|
||||
of the node's IP address:
|
||||
|
||||
```bash
|
||||
kubectl apply -f k3s/expose-ingress.yaml
|
||||
curl -si "http://<node-ip>/"
|
||||
```
|
||||
|
||||
#### Option 2: ServiceLB
|
||||
|
||||
k3s also includes the ServiceLB load balancer. The single `LoadBalancer`
|
||||
Service in [k3s/expose-servicelb.yaml](k3s/expose-servicelb.yaml) exposes the
|
||||
app on port 8080 of the node's IP address, without an Ingress:
|
||||
|
||||
```bash
|
||||
kubectl apply -f k3s/expose-servicelb.yaml
|
||||
curl -si "http://<node-ip>:8080"
|
||||
```
|
||||
|
||||
On a multi-node cluster, push the image to a registry instead, so every node can
|
||||
pull it.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: ok-server
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ok-server
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: ok-server
|
||||
spec:
|
||||
containers:
|
||||
- name: ok-server
|
||||
image: ok-server
|
||||
imagePullPolicy: Never
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
@@ -0,0 +1,26 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: ok-server
|
||||
spec:
|
||||
selector:
|
||||
app: ok-server
|
||||
ports:
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: ok-server
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: ok-server
|
||||
port:
|
||||
number: 8080
|
||||
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: ok-server
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
selector:
|
||||
app: ok-server
|
||||
ports:
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
Reference in New Issue
Block a user