Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saiyam1814/96bde99d23635ae9c5babeb78f1060c0 to your computer and use it in GitHub Desktop.
Save saiyam1814/96bde99d23635ae9c5babeb78f1060c0 to your computer and use it in GitHub Desktop.
k3s deepdive
Katakoda Ubuntu Playground
https://www.katacoda.com/courses/ubuntu/playground
Install k3s
curl -sfL https://get.k3s.io | sh -
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
Rancher deployment:
---
kind: Namespace
apiVersion: v1
metadata:
name: cattle-system
labels:
name: cattle-system
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: cattle-admin
namespace: cattle-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cattle-crb
namespace: cattle-system
subjects:
- kind: ServiceAccount
name: cattle-admin
namespace: cattle-system
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
---
kind: Deployment
apiVersion: apps/v1
metadata:
namespace: cattle-system
name: cattle
spec:
replicas: 1
selector:
matchLabels:
app: cattle
template:
metadata:
labels:
app: cattle
spec:
serviceAccountName: cattle-admin
containers:
- image: rancher/rancher:v2.3.0
imagePullPolicy: Always
name: cattle-server
ports:
- containerPort: 80
protocol: TCP
- containerPort: 443
protocol: TCP
volumeMounts:
- mountPath: /var/lib/rancher
name: rancher
volumes:
- name: rancher
hostPath:
path: /home/rancher
---
apiVersion: v1
kind: Service
metadata:
namespace: cattle-system
name: cattle-service
spec:
ports:
- name: http
port: 80
- name: https
port: 443
selector:
app: cattle
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: cattle-ingress
namespace: cattle-system
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: cattle-service
servicePort: http
FAQ:
why k3s on IOT
devops for IOT
ha, scalibility, efficient use deployment to IOt edge
HA architecture
https://rancher.com/docs/k3s/latest/en/architecture/#high-availability-with-an-external-db
Agents will register with the server using the node cluster secret along with a randomly generated password for the node,
stored at /etc/rancher/node/password. The server will store the passwords for individual nodes at
/var/lib/rancher/k3s/server/cred/node-passwd, and any subsequent attempts must use the same password.
Why K3s:
for speed, easy to setup, easy to use, save cost, best for edge devices
why sqlitee over etcd
It's small. I've been experimenting with different backends for storage. To me SQL makes the most sense as I have a lot of flexibility. So I can do embedded with sqlite, I can get a hosted version of something with RDS, I can run mysql/postgres myself, I can run newsql like CockroachDB or TiDB.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment