Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
docker:kubernetes [2020/05/25 11:44] – [Master] tmadedocker:kubernetes [2020/06/08 16:18] – [Reset k8s] tmade
Line 203: Line 203:
  
 #author:  Thomas Roehm #author:  Thomas Roehm
-#version: 1.4+#version: 1.5
  
 USER="kubernetes" USER="kubernetes"
Line 214: Line 214:
 DASBOARD="/home/kubernetes/dashboard" DASBOARD="/home/kubernetes/dashboard"
 # filename such as "kubernetes-dashboard-v2.0.0-rc5.yaml" expected # filename such as "kubernetes-dashboard-v2.0.0-rc5.yaml" expected
-DASHVERS="v2.0.0-rc5"+DASHVERS="v2.0.1"
 PODNETWORKADDON="192.168.0.0/16" PODNETWORKADDON="192.168.0.0/16"
  
Line 220: Line 220:
 echo "Setup -------------k8s--------------" echo "Setup -------------k8s--------------"
 echo "" echo ""
-su - kubernetes -c "kubectl version"+su - kubernetes -c "kubectl version 2> /dev/null"
 echo "" echo ""
 su - kubernetes -c "read -s -n 1 -p \"Press any key to continue . . .\"" su - kubernetes -c "read -s -n 1 -p \"Press any key to continue . . .\""
Line 284: Line 284:
  
 echo "" echo ""
-read -p "Do you want to schedule pods on your master? Please enter \"y\" or \"n\": " SCHEDULE+while [ -z $SCHEDULE ] ; 
 +do 
 +      read -p "Do you want to schedule pods on your master? Please enter \"y\" or \"n\": " SCHEDULE 
 +      echo "Please enter \"y\" or \"n\"" 
 +done 
 + 
 +echo ""
 echo "You´ve entered:  \"$SCHEDULE\"" echo "You´ve entered:  \"$SCHEDULE\""
 echo "" echo ""
 +
 if [ $SCHEDULE = y ] if [ $SCHEDULE = y ]
 then then
Line 698: Line 705:
 #/bin/bash #/bin/bash
  
-echo "Important: The \"Common Name\" (CN) must be the same as the ServiceAccount name (e. g. tmade)!"+echo "" 
 +echo "Important: The \"Common Name\" (CN) must be the same as the ServiceAccount name (e. g. MyHostname)!"
  
 #author:  Thomas Roehm #author:  Thomas Roehm
-#version: 1.3+#version: 1.4
  
 C="DE" C="DE"
 ST="BW" ST="BW"
 L="MyCity" L="MyCity"
-O="tmade+O="MyCompany
-OU="Cluster+OU="MyDepartment
-CN="tmade"+CN="MyHostname"
 MAIL="test@test.com" MAIL="test@test.com"
 CERT="$(echo ~/certs)" CERT="$(echo ~/certs)"
Line 725: Line 733:
 fi fi
  
-openssl req -out kubecfg-${CN}.csr -new -newkey rsa:4096 -nodes -keyout kubecfg-${CN}.key -subj "/\C=${C}/ST=${ST}/L=${L}/O=${O}/OU=${OU}/CN=${CN}/emailAddress=${MAIL}"+dd if=/dev/urandom of=~/.rnd bs=256 count=1 2> /dev/null 
 +openssl req -out kubecfg-${CN}.csr -new -newkey rsa:4096 -nodes -keyout kubecfg-${CN}.key -subj "/C=${C}/ST=${ST}/L=${L}/O=${O}/OU=${OU}/CN=${CN}/emailAddress=${MAIL}"
 sudo openssl x509 -req -in kubecfg-${CN}.csr -CA /etc/kubernetes/pki/ca.crt -CAkey /etc/kubernetes/pki/ca.key -CAcreateserial -out kubecfg-${CN}.crt -days 1000 -sha256 sudo openssl x509 -req -in kubecfg-${CN}.csr -CA /etc/kubernetes/pki/ca.crt -CAkey /etc/kubernetes/pki/ca.key -CAcreateserial -out kubecfg-${CN}.crt -days 1000 -sha256
 openssl pkcs12 -export -clcerts -inkey kubecfg-${CN}.key -in kubecfg-${CN}.crt -out kubecfg-${CN}.p12 -name "kubernetes-client" openssl pkcs12 -export -clcerts -inkey kubecfg-${CN}.key -in kubecfg-${CN}.crt -out kubecfg-${CN}.p12 -name "kubernetes-client"
Line 1250: Line 1259:
  
 === Install nginx ingress-controller === === Install nginx ingress-controller ===
 +
 +Check also on https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/
  
 <code sh install-nginx-ingress-controller.sh> <code sh install-nginx-ingress-controller.sh>
Line 1255: Line 1266:
  
 #author:  Thomas Roehm #author:  Thomas Roehm
-#version: 1.1+#version: 1.2
  
 VERSION="1.6.3" VERSION="1.6.3"
-HOME="/home/kubernetes"+USER="kubernetes" 
 +HOME="/home/${USER}"
 FILE="${HOME}/kubernetes-ingress" FILE="${HOME}/kubernetes-ingress"
  
-if  [ -$FILE ]+if  [ -${FILE]
 then then
-        echo "Downloading Ingress..." 
-else 
         echo ""         echo ""
         echo "${FILE} exists, renaming..."         echo "${FILE} exists, renaming..."
Line 1270: Line 1280:
  
         mv ${FILE} ${FILE}.bak         mv ${FILE} ${FILE}.bak
 +else
 +        echo ""
 +        echo "Downloading Ingress..."
 +        echo ""
 fi fi
  
 +cd ${HOME}
 git clone https://github.com/nginxinc/kubernetes-ingress/ git clone https://github.com/nginxinc/kubernetes-ingress/
 cd kubernetes-ingress/deployments cd kubernetes-ingress/deployments
 git checkout v${VERSION} git checkout v${VERSION}
 +chown -R ${USER}:${USER} ${FILE}
  
 echo "" echo ""
Line 1280: Line 1296:
 echo "" echo ""
  
-kubectl apply -f common/ns-and-sa.yaml+su - kubernetes -c "kubectl apply -f ~/kubernetes-ingress/deployments/common/ns-and-sa.yaml"
  
 echo "" echo ""
Line 1286: Line 1302:
 echo "" echo ""
  
-kubectl apply -f rbac/rbac.yaml+su - kubernetes -c "kubectl apply -f ~/kubernetes-ingress/deployments/rbac/rbac.yaml"
  
 echo "" echo ""
Line 1292: Line 1308:
 echo "" echo ""
  
-kubectl apply -f common/default-server-secret.yaml+su - kubernetes -c "kubectl apply -f ~/kubernetes-ingress/deployments/common/default-server-secret.yaml"
  
 echo "" echo ""
Line 1298: Line 1314:
 echo "" echo ""
  
-kubectl apply -f common/nginx-config.yaml+su - kubernetes -c "kubectl apply -f ~/kubernetes-ingress/deployments/common/nginx-config.yaml"
  
 echo "" echo ""
Line 1304: Line 1320:
 echo "" echo ""
  
-kubectl apply -f common/custom-resource-definitions.yaml+su - kubernetes -c "kubectl apply -f ~/kubernetes-ingress/deployments/common/custom-resource-definitions.yaml"
  
 echo "" echo ""
Line 1311: Line 1327:
  
 #kubectl apply -f deployment/nginx-ingress.yaml #kubectl apply -f deployment/nginx-ingress.yaml
-kubectl apply -f daemon-set/nginx-ingress.yaml+su - kubernetes -c "kubectl apply -f ~/kubernetes-ingress/deployments/daemon-set/nginx-ingress.yaml"
  
 echo "" echo ""
 echo "Ingress Controller has been installed." echo "Ingress Controller has been installed."
 +echo ""
 +echo "Status - please press \"ctrl + c\" when all pods are running"
 echo "" echo ""
  
-kubectl get pods -A -o wide+watch kubectl get pods -A -o wide
 </code> </code>
  
Line 1381: Line 1399:
 #          servicePort: 80 #          servicePort: 80
  
 +</code>
 +
 +Another example:
 +
 +<code>
 +apiVersion: networking.k8s.io/v1beta1
 +kind: Ingress
 +metadata:
 +  name: simple-fanout-example
 +  annotations:
 +    nginx.ingress.kubernetes.io/rewrite-target: /
 +spec:
 +  rules:
 +  - host: foo.bar.com
 +    http:
 +      paths:
 +      - path: /foo
 +        backend:
 +          serviceName: service1
 +          servicePort: 4200
 +      - path: /bar
 +        backend:
 +          serviceName: service2
 +          servicePort: 8080
 </code> </code>
  
Line 1441: Line 1483:
 ====Alias====  ====Alias==== 
  
-  echo "alias kg='kubectl get'" >> /etc/bash.bashrc+<code> 
 +cat >> /etc/bash.bashrc <<EOF 
 +#A41 
 +alias ..='cd ../.' 
 +alias ...='cd ../../.' 
 +alias kc='kubectl' 
 +EOF 
 +</code> 
 + 
 +Activate: 
 + 
 +  source /etc/bash.bashrc
  
  
Line 1475: Line 1528:
  
 #author:  Thomas Roehm #author:  Thomas Roehm
-#version: 1.1+#version: 1.2
  
 echo "You´re running version:" echo "You´re running version:"
Line 1484: Line 1537:
  
 apt-get update apt-get update
-apt-cache policy kubeadm+apt-cache policy kubeadm  | head -n 30
  
 echo "" echo ""
Line 1591: Line 1644:
  
 #author:  Thomas Roehm #author:  Thomas Roehm
-#version: 1.1+#version: 1.3
  
 echo "You´re running version:" echo "You´re running version:"
 echo "" echo ""
-su - kubernetes -c "kubectl version"+kubectl version 2> /dev/null
 echo "" echo ""
 read -s -n 1 -p "Press any key to continue . . ." read -s -n 1 -p "Press any key to continue . . ."
 #su - kubernetes -c "read -s -n 1 -p \"Press any key to continue . . .\"" #su - kubernetes -c "read -s -n 1 -p \"Press any key to continue . . .\""
 apt-get update apt-get update
-apt-cache policy kubeadm+apt-cache policy kubeadm | head -n 30
  
 echo "" echo ""
Line 1662: Line 1715:
  
  
-====Reset k8s==== 
  
-<code sh reset-k8s.sh> 
-#!/bin/bash 
- 
-#author:  Thomas Roehm 
-#version: 1.1 
- 
-HOME="/home/kubernetes" 
- 
-sudo kubeadm reset -f 
-iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X 
-rm -r ${HOME}/.kube 
-</code> 
 ====helm==== ====helm====
  
docker/kubernetes.txt · Last modified: 2022/10/03 15:49 by tmade
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki