From b6183f70e28fce89e67d380261f5e77e5264d41c Mon Sep 17 00:00:00 2001 From: Sander van Vugt Date: Tue, 21 Jul 2020 14:00:26 +0200 Subject: [PATCH] updates --- kube-setup.sh | 73 ++++++++++++++++++++++++++++------------ nginx-cm.yml | 20 +++++++++++ nginx-custom-config.conf | 8 +++++ test-cm-pod.yaml | 15 +++++++++ 4 files changed, 94 insertions(+), 22 deletions(-) create mode 100644 nginx-cm.yml create mode 100644 nginx-custom-config.conf create mode 100644 test-cm-pod.yaml diff --git a/kube-setup.sh b/kube-setup.sh index 9c2fd3d..24d5fa8 100755 --- a/kube-setup.sh +++ b/kube-setup.sh @@ -1,35 +1,64 @@ #!/bin/bash # -# verified on Fedora 31 WS +# verified on Fedora 31 and Ubuntu LTS 20.04 + +echo this script works on Fedora 31 and Ubuntu 20.04 +echo it does NOT currently work on Fedora 32 +echo it requires the machine where you run it to have 6GB of RAM or more +echo press Enter to continue +read + +# setting MYOS variable +MYOS=$(hostnamectl | awk '/Operating/ { print $3 }') +OSVERSION=$(hostnamectl | awk '/Operating/ { print $4 }') + egrep '^flags.*(vmx|svm)' /proc/cpuinfo || (echo enable CPU virtualization support and try again && exit 9) -dnf clean all -dnf -y upgrade +# debug MYOS variable +echo MYOS is set to $MYOS -# install KVM software -dnf install @virtualization -y -systemctl enable --now libvirtd +#### Fedora config +if [ $MYOS = "Fedora" ] +then + #if [ $OSVERSION = 32 ] + #then + # echo Fedora 32 is not currently supported + # exit 9 + #fi + + sudo dnf clean all + sudo dnf -y upgrade + + # install KVM software + sudo dnf install @virtualization -y + sudo systemctl enable --now libvirtd + sudo usermod -aG libvirt `id -un` +fi + +### Ubuntu config +if [ $MYOS = "Ubuntu" ] +then + sudo apt-get update -y + sudo apt-get install -y apt-transport-https curl + sudo apt-get upgrade -y + sudo apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils + + sudo adduser `id -un` libvirt + sudo adduser `id -un` kvm +fi # install kubectl -echo installing kubectl -cat < /etc/yum.repos.d/kubernetes.repo -[kubernetes] -name=Kubernetes -baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 -enabled=1 -gpgcheck=1 -repo_gpgcheck=1 -gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg -EOF - -dnf install -y kubectl +curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl +chmod +x ./kubectl +sudo mv ./kubectl /usr/local/bin/kubectl # install minikube echo downloading minikube, check version curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -chmod +x minikube -mv minikube /usr/local/bin +sudo chmod +x minikube +sudo mv minikube /usr/local/bin + +# start minikube +minikube start --memory 4096 --vm-driver=kvm2 -echo at this point, reboot your Fedora Workstation. After reboot, manually run as non-root -echo minikube start --memory 4096 --vm-driver=kvm2 diff --git a/nginx-cm.yml b/nginx-cm.yml new file mode 100644 index 0000000..9274ebc --- /dev/null +++ b/nginx-cm.yml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Pod +metadata: + name: nginx-cm + labels: + role: web +spec: + containers: + - name: nginx-cm + image: nginx + volumeMounts: + - name: conf + mountPath: /etc/nginx/conf.d + volumes: + - name: conf + configMap: + name: nginx-cm + items: + - key: nginx-custom-config.conf + path: default.conf diff --git a/nginx-custom-config.conf b/nginx-custom-config.conf new file mode 100644 index 0000000..c872eed --- /dev/null +++ b/nginx-custom-config.conf @@ -0,0 +1,8 @@ +server { + listen 8888; + server_name localhost; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } +} diff --git a/test-cm-pod.yaml b/test-cm-pod.yaml new file mode 100644 index 0000000..6082068 --- /dev/null +++ b/test-cm-pod.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: test-pod +spec: + containers: + - name: test + image: nginx + env: + - name: COLOR + valueFrom: + configMapKeyRef: + name: myconfig + key: color + restartPolicy: Never