Microk8s: Difference between revisions

From Essential
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
==AUTOMATED INSTALL==
==AUTOMATED INSTALL==
* Optional define:
<syntaxhighlight lang="bash">
export dhcpList=192.168.1.11-192.168.1.19
</syntaxhighlight>
* Execute :
* Execute :
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 6: Line 10:
curl https://infocepo.com/wiki/index.php/Special:Export/Microk8s 2>/dev/null |tac |sed -r '0,/'"#"'24cc42#/d' |tac |sed -r '0,/'"#"'24cc42#/d' |sed 's/'"&"'amp;/\&/g;s/'"&"'gt;/>/g;s/'"&"'lt;/</g' >$$ &&\
curl https://infocepo.com/wiki/index.php/Special:Export/Microk8s 2>/dev/null |tac |sed -r '0,/'"#"'24cc42#/d' |tac |sed -r '0,/'"#"'24cc42#/d' |sed 's/'"&"'amp;/\&/g;s/'"&"'gt;/>/g;s/'"&"'lt;/</g' >$$ &&\
bash $$ &&\
bash $$ &&\
cd -
cd - >/dev/null
</syntaxhighlight>
</syntaxhighlight>
==code==
==code==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 17: Line 22:
#microk8s.start
#microk8s.start
#watch microk8s status
#watch microk8s status
microk8s enable helm3 dns community hostpath-storage ingress
microk8s enable helm3 dns community hostpath-storage ingress rbac
#microk8s disable metallb
#microk8s disable metallb
microk8s enable metallb:${dhcpList}
microk8s enable metallb:${dhcpList}
Line 23: Line 28:
snap install kubectl --classic
snap install kubectl --classic
snap alias microk8s.helm3 helm
snap alias microk8s.helm3 helm
export KUBECONFIG=${HOME}/.kube/config
mkdir -p ${HOME}/.kube
microk8s.kubectl config view --raw >$KUBECONFIG
kubectl create namespace infra-root
kubectl config set-context --current --namespace=infra-root
#snap unalias
#snap unalias
mkdir -p ~/old &&\
cd ~/old &&\
curl https://infocepo.com/wiki/index.php/Special:Export/K8s-users 2>/dev/null |tac |sed -r '0,/'"#"'24cc42#/d' |tac |sed -r '0,/'"#"'24cc42#/d' |sed 's/'"&"'amp;/\&/g;s/'"&"'gt;/>/g;s/'"&"'lt;/</g' >$$ &&\
bash $$ &&\
cd - >/dev/null
#24cc42#
#24cc42#
</syntaxhighlight>
</syntaxhighlight>
Line 29: Line 44:
==FIRST APP==
==FIRST APP==
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
hostName=
kubectl create namespace sandbox
kubectl create namespace sandbox
kubectl config set-context --current --namespace=sandbox
kubectl config set-context --current --namespace=sandbox
Line 43: Line 60:
spec:
spec:
   rules:
   rules:
   - host: "sandbox.c1.mi.infocepo.com"
   - host: "${hostName}"
     http:
     http:
       paths:
       paths:

Latest revision as of 09:59, 20 July 2023

AUTOMATED INSTALL

  • Optional define:
export dhcpList=192.168.1.11-192.168.1.19
  • Execute :
mkdir -p ~/old &&\
cd ~/old &&\
curl https://infocepo.com/wiki/index.php/Special:Export/Microk8s 2>/dev/null |tac |sed -r '0,/'"#"'24cc42#/d' |tac |sed -r '0,/'"#"'24cc42#/d' |sed 's/'"&"'amp;/\&/g;s/'"&"'gt;/>/g;s/'"&"'lt;/</g' >$$ &&\
bash $$ &&\
cd - >/dev/null

code

#24cc42#
#https://kubernetes.io/blog/2019/11/26/running-kubernetes-locally-on-linux-with-microk8s/
[ -z "${dhcpList}" ] &&dhcpList=192.168.1.21-192.168.1.29

snap install microk8s --classic
#microk8s.start
#watch microk8s status
microk8s enable helm3 dns community hostpath-storage ingress rbac
#microk8s disable metallb
microk8s enable metallb:${dhcpList}
#snap alias microk8s.kubectl kubectl
snap install kubectl --classic
snap alias microk8s.helm3 helm
export KUBECONFIG=${HOME}/.kube/config
mkdir -p ${HOME}/.kube
microk8s.kubectl config view --raw >$KUBECONFIG
kubectl create namespace infra-root
kubectl config set-context --current --namespace=infra-root
#snap unalias
mkdir -p ~/old &&\
cd ~/old &&\
curl https://infocepo.com/wiki/index.php/Special:Export/K8s-users 2>/dev/null |tac |sed -r '0,/'"#"'24cc42#/d' |tac |sed -r '0,/'"#"'24cc42#/d' |sed 's/'"&"'amp;/\&/g;s/'"&"'gt;/>/g;s/'"&"'lt;/</g' >$$ &&\
bash $$ &&\
cd - >/dev/null
#24cc42#

FIRST APP

hostName=

kubectl create namespace sandbox
kubectl config set-context --current --namespace=sandbox
#kubectl delete deployment sandbox
kubectl create deployment sandbox --image=registry.k8s.io/e2e-test-images/agnhost:2.39 -- /agnhost netexec --http-port=8080
#kubectl delete svc sandbox
kubectl expose deployment sandbox --type=LoadBalancer --port=8080
kubectl delete ingress sandbox
cat <<EOF |kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sandbox
spec:
  rules:
  - host: "${hostName}"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: sandbox
            port:
              number: 8080
EOF