Skip to content

jeremybusk/lxd-microk8s-getting-started

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 

Repository files navigation

lxd-microk8s-getting-started

Kubernetes using microk8s in lxd

Anatomy of Kubernetes

Using Ubuntu and LXD to Create a Quick and Dirty HA k8s Environment

Init LXD - https://linuxcontainers.org/lxd/getting-started-cli/

apt install zfsutils-linux
lxd init
lxc profile create microk8s
wget https://raw.githubusercontent.com/ubuntu/microk8s/master/tests/lxc/microk8s-zfs.profile -O microk8s.profile && cat microk8s.profile | lxc profile edit microk8s && rm microk8s.profile
lxc launch -p default -p microk8s ubuntu:20.04 testk1

Note what you are doing from a security point of view with the microk8s profile.

Prep LXC containers apparmor

lxc shell testk1
snap install microk8s --classic
cat > /etc/rc.local <<EOF
#!/bin/bash
apparmor_parser --replace /var/lib/snapd/apparmor/profiles/snap.microk8s.*
exit 0
EOF
chmod +x /etc/rc.local

run this on testk2 and testk3

Join microk8s nodes together in HA cluster

lxc shell testk1
microk8s add-node  # This needs to be ran after each join as it changes on HA cluster modification
# Copy command it shows you to run on other two nodes

Add testk1 and testk2

Enable Add-ons

https://microk8s.io/docs/addons

microk8s enable ingress
microk8s enable dns
micork8s status (You can see 

Run your first deployment

Here is a simple example

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  type: NodePort
  selector:
    app: nginx
  ports:
      # By default and for convenience, the `targetPort` is set to the same value as the `port` field.
    - port: 80
      targetPort: 80
      # Optional field
      # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)
      nodePort: 30001

microk8s.kubectl apply -f my-nginx.yml

Complex Operator

https://www.zabbix.com/documentation/current/manual/installation/containers

https://github.com/zabbix/zabbix-docker/blob/5.2/kubernetes.yaml

https://github.com/zabbix/zabbix-docker

https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/ https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#deploymentspec-v1-apps

https://gitlab.com/frenchtoasters/zabbix-operator

https://assets.zabbix.com/files/events/zabbix_summit_2020/Tyler_French_Zabbix_meets_Kubernetes.pdf

About

Kubernetes using microk8s in lxd

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published