Install K3s with metallb and nginx-ingress
server
ip
role
k3s-control.dev.local
192.168.1.100
control-plane
k3s-node-01.dev.local
192.168.1.101
node-01
disable traefik, servicelb
curl -sfL https://get.k3s.io | sh -s - server --disable=traefik,servicelb
echo ' alias kubectl="sudo k3s kubectl"' >> ~ /.bashrc
echo ' alias k="kubectl"' >> ~ /.bashrc
echo " source <(kubectl completion bash)" >> ~ /.bashrc
echo " complete -o default -F __start_kubectl k" >> ~ /.bashrc
source .bashrc
sudo cat /var/lib/rancher/k3s/server/token
K1070f0efca2cc2f23adfe6ad2a1a58133903e17bfe9ffd15d7648940c483f0c21f::server:00296542ce6f21970fecd8b4964e16fe
export TOKEN=K1070f0efca2cc2f23adfe6ad2a1a58133903e17bfe9ffd15d7648940c483f0c21f::server:00296542ce6f21970fecd8b4964e16fe
export K3S_URL=https://192.168.1.100:6443
curl -sfL https://get.k3s.io | K3S_URL=$K3S_URL K3S_TOKEN=$TOKEN sh -
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.5/config/manifests/metallb-native.yaml
apiVersion : metallb.io/v1beta1
kind : IPAddressPool
metadata :
name : production
namespace : metallb-system
spec :
addresses :
- 192.168.1.200-192.168.1.200
apiVersion : metallb.io/v1beta1
kind : L2Advertisement
metadata :
name : example
namespace : metallb-system
spec :
ipAddressPools :
- production
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.9.4/deploy/static/provider/cloud/deploy.yaml
Example Create Application
kubectl create namespace app
kubectl create deployment app --image gcr.io/google-samples/hello-app:1.0 --namespace app
kubectl create svc clusterip app --namespace app --tcp 8080:8080
kubectl create ingress app --class=nginx --namespace app --rule foo.bar/* =app:8080
kubectl create secret docker-registry SECRET_NAME \
--namespace=YOUR_NAMESPACE \
--docker-server=docker.io \
--docker-username=USERNAME \
--docker-password=PASSWORD \
--docker-email=EMAIL_ADDRESS \
--output=yaml \
--dry-run=client
kubectl annotate service --namespace app app metallb.universe.tf/allow-shared-ip=" mgmt"
kubectl taint node k3s-control-plane-name k3s-controlplane=true:NoSchedule
Single Host k3s with calico
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC=" --flannel-backend=none --disable-network-policy --cluster-cidr=192.168.0.0/16" sh -
kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.0/manifests/calico.yaml
MultiHost k3s with calico and Metallb
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC=" --flannel-backend=none --disable-network-policy --disable=traefik,servicelb --cluster-cidr=192.168.0.0/16" sh -
kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.0/manifests/calico.yaml
export TOKEN=K102a49ba59c8c085641e2067ddbfe3ea139d83843044664bbd7c067f4f5163c165::server:e3389daae45fc2643fdc516b613646f7
export K3S_URL=https://control_plane_ip_address:6443
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.5/config/manifests/metallb-native.yaml
export TOKEN=K102a49ba59c8c085641e2067ddbfe3ea139d83843044664bbd7c067f4f5163c165::server:e3389daae45fc2643fdc516b613646f7
export K3S_URL=https://control_plane_ip_address:6443
curl -sfL https://get.k3s.io | K3S_URL=$K3S_URL K3S_TOKEN=$TOKEN sh -