Last active
November 1, 2023 06:02
-
-
Save icebob/9c7cc01fbc9fb6883b5c3398e26fb3d5 to your computer and use it in GitHub Desktop.
Start K3S Cluster on Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
server: | |
image: "rancher/k3s:latest" | |
command: server | |
tmpfs: | |
- /run | |
- /var/run | |
privileged: true | |
environment: | |
- K3S_TOKEN=token1234567890 | |
- K3S_NODE_NAME=master | |
- K3S_KUBECONFIG_OUTPUT=/output/kube.config | |
- K3S_KUBECONFIG_MODE=666 | |
volumes: | |
- k3s-server:/var/lib/rancher/k3s | |
- .:/output | |
ports: | |
- 6443:6443 | |
- 80:80 | |
- 443:443 | |
- 8080:8080 | |
restart: unless-stopped | |
worker1: | |
image: "rancher/k3s:latest" | |
tmpfs: | |
- /run | |
- /var/run | |
privileged: true | |
environment: | |
- K3S_URL=https://server:6443 | |
- K3S_TOKEN=token1234567890 | |
- K3S_NODE_NAME=worker-1 | |
volumes: | |
- k3s-worker1:/var/lib/rancher/k3s | |
restart: unless-stopped | |
worker2: | |
image: "rancher/k3s:latest" | |
tmpfs: | |
- /run | |
- /var/run | |
privileged: true | |
environment: | |
- K3S_URL=https://server:6443 | |
- K3S_TOKEN=token1234567890 | |
- K3S_NODE_NAME=worker-2 | |
volumes: | |
- k3s-worker2:/var/lib/rancher/k3s | |
restart: unless-stopped | |
volumes: | |
k3s-server: {} | |
k3s-worker1: {} | |
k3s-worker2: {} |
With Longhorn:
version: '3'
services:
server:
image: "rancher/k3s:latest"
command: server
tmpfs:
- /run
- /var/run
privileged: true
environment:
- K3S_TOKEN=token1234567890
- K3S_NODE_NAME=master
- K3S_KUBECONFIG_OUTPUT=/output/kube.config
- K3S_KUBECONFIG_MODE=666
volumes:
- k3s-server:/var/lib/rancher/k3s
- k3s-server-lh:/var/lib/rancher/longhorn
- .:/output
ports:
- 6443:6443
- 80:80
- 443:443
- 8080:8080
restart: unless-stopped
worker1:
image: "rancher/k3s:latest"
tmpfs:
- /run
- /var/run
privileged: true
environment:
- K3S_URL=https://server:6443
- K3S_TOKEN=token1234567890
- K3S_NODE_NAME=worker-1
volumes:
- k3s-worker1:/var/lib/rancher/k3s
- k3s-worker1-lh:/var/lib/rancher/longhorn
restart: unless-stopped
worker2:
image: "rancher/k3s:latest"
tmpfs:
- /run
- /var/run
privileged: true
environment:
- K3S_URL=https://server:6443
- K3S_TOKEN=token1234567890
- K3S_NODE_NAME=worker-2
volumes:
- k3s-worker2:/var/lib/rancher/k3s
- k3s-worker2-lh:/var/lib/rancher/longhorn
restart: unless-stopped
volumes:
k3s-server: {}
k3s-worker1: {}
k3s-worker2: {}
k3s-server-lh: {}
k3s-worker1-lh: {}
k3s-worker2-lh: {}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Start K3s cluster
Copy kube config
Install kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl chmod +x ./kubectl sudo mv ./kubectl /usr/local/bin/kubectl kubectl version
Test cluster
Install K9s