Skip to content

Instantly share code, notes, and snippets.

@JasonkayZK
Last active February 6, 2023 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JasonkayZK/670d578f9bb494c56c6061466dd7314f to your computer and use it in GitHub Desktop.
Save JasonkayZK/670d578f9bb494c56c6061466dd7314f to your computer and use it in GitHub Desktop.
k3s-helm-install.sh
# Install K3S
curl -sfL https://get.k3s.io | sh -
# Copy k3s config
mkdir $HOME/.kube
sudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
sudo chmod 644 $HOME/.kube/config
# Check K3S
kubectl get pods -n kube-system
# Install Kuboard
kubectl apply -f https://addons.kuboard.cn/kuboard/kuboard-v3.yaml
# Check Kuboard
kubectl get pods -n kuboard -o wide
# Create Storage class
# kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
# kubectl get storageclass
# Download & install Helm
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > install-helm.sh
chmod u+x install-helm.sh
./install-helm.sh
helm init
# Or: https://www.cnblogs.com/breezey/p/9398927.html
# helm init --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.9.0 --service-account=tiller --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
# Link Helm with Tiller
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
helm init --service-account tiller --upgrade
# Check Helm
helm repo update
helm search postgres
# Install NATS with Helm
# https://hub.helm.sh/charts/bitnami/nats
helm install --name nats --namespace demo \
--set auth.enabled=true,auth.user=admin,auth.password=admin1234 \
stable/nats
# Check
helm list
kubectl get svc -n demo
# Create a port forward to NATS (blocking the terminal)
kubectl port-forward svc/nats-client 4222 -n demo
# Delete NATS
helm delete nats
# Working DNS with ufw https://github.com/rancher/k3s/issues/24#issuecomment-515003702
# sudo ufw allow in on cni0 from 10.42.0.0/16 comment "K3s rule"
# More info:
# https://zhuanlan.zhihu.com/p/125499493/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment