From 1d26bb4215d3c84d3daed8e1f9b512ae7c13972b Mon Sep 17 00:00:00 2001 From: Sebastian Rieger Date: Sun, 2 Jun 2024 21:11:26 +0200 Subject: [PATCH] removed old terraform k8s examples and refered to current repo --- kubernetes-example/kubectl-intro.md | 168 ---------------------------- kubernetes-example/nginx.yml | 20 ---- kubernetes-example/service.yml | 16 --- terraform/rke2-terraform/README.md | 3 + 4 files changed, 3 insertions(+), 204 deletions(-) delete mode 100644 kubernetes-example/kubectl-intro.md delete mode 100644 kubernetes-example/nginx.yml delete mode 100644 kubernetes-example/service.yml diff --git a/kubernetes-example/kubectl-intro.md b/kubernetes-example/kubectl-intro.md deleted file mode 100644 index 268500e..0000000 --- a/kubernetes-example/kubectl-intro.md +++ /dev/null @@ -1,168 +0,0 @@ -# Introduction to kubectl - -## Prerequisites - -For using this you must install the following tools: - -- Python -- Pip -- Kubectl -- Openstack-Client - -### Python - -Install python and pip for your OS, if it is not installed. This is already done at the NetLab PCs. - -### Installing kubectl and arkade - -Run this in a **bash** terminal to download arkade and install kubectl: - -For windows you can use e.g. the **Git Bash** terminal. - -```bash -curl -sLS https://dl.get-arkade.dev | sh -arkade get kubectl -# To load the path to the binary -export PATH=$PATH:$HOME/.arkade/bin/ -``` - -With arkade you can also install other tools: ```arkade get``` to see all possibilities. - -### Openstack Client - -To install the Openstack client and the magnum package: - -If you are using Windows, you must start the bash terminal with **Administrator** privileges! - -```bash -pip3 install openstackclient python-magnumclient -# Download the Openstack RC File from your Openstack account -# Load the file -source {USERNAME}-openrc.sh -``` - -### Download the kubeconfig - -Download the kubeconfig file for your cluster from OpenStack. - -```bash -# Before using this, check if Openstack RC File is loaded! -openstack coe cluster config {CLUSTER_NAME} -# Then run the given command in terminal -export ... -# Now you are able to run kubectl commands at your Kubernetes cluster -``` - -## Deployment of the needed description in kubernetes - -These are two approaches to create the description in Kubernetes: - -```bash -# create a namespace -kubectl create namespace web-test - -# Then choose one of the following ways: -# (1) Create the description -kubectl create -f nginx.yml -f service.yml - -# (2) Create or update descriptions if existing -kubectl apply -f nginx.yml -f service.yml -``` - -## To show it is working - -Here are some useful commands: - -```bash -# show nodes -kubectl get nodes - -# show pods for our namespace -kubectl get -n web-test pods - -# show deployments for our namespace -kubectl get -n web-test deployment - -# show services for our namespace -kubectl get -n web-test service - -# show logs of deployed nginx instances -kubectl logs -n web-test deployment/nginx-deployment -``` - -## Scaling up and down - -```bash -# scale up instances to 5 -kubectl scale -n web-test deployment/nginx-deployment --replicas=5 - -# scale down instances again to 3 -kubectl scale -n web-test deployment/nginx-deployment --replicas=3 - -``` - - -## To see it is working in the browser ;) - -The nginx instances are reachable at the floating ips of the **node**-instances at port **30007** in our case. - - -## Many other things can be done ;) - -- Autoscaling -- Detailled Service functions (LoadBalancer, ...) -- Dashboard -- FaaS Setup ;) -- ... - - -## Appendix - -### Nginx description - -*nginx.yml:* -```yml -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx-deployment - namespace: web-test -spec: - selector: - matchLabels: - app: nginx-deployment - replicas: 3 # tells deployment to run 3 pods matching the template - template: - metadata: - labels: - app: nginx-deployment - spec: - containers: - - name: nginx - image: nginx:latest - ports: - - containerPort: 80 - -``` - -### Nginx service description - -*service.yml:* -```yml -apiVersion: v1 -kind: Service -metadata: - name: nginx-service - namespace: web-test -spec: - type: NodePort - selector: - app: nginx-deployment - ports: - # By default and for convenience, the `targetPort` is set to the same value as the `port` field. - - port: 80 - targetPort: 80 - # Optional field - # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767) - nodePort: 30007 -``` \ No newline at end of file diff --git a/kubernetes-example/nginx.yml b/kubernetes-example/nginx.yml deleted file mode 100644 index e14fd3b..0000000 --- a/kubernetes-example/nginx.yml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx-deployment - namespace: web-test -spec: - selector: - matchLabels: - app: nginx-deployment - replicas: 3 # tells deployment to run 3 pods matching the template - template: - metadata: - labels: - app: nginx-deployment - spec: - containers: - - name: nginx - image: nginx:latest - ports: - - containerPort: 80 \ No newline at end of file diff --git a/kubernetes-example/service.yml b/kubernetes-example/service.yml deleted file mode 100644 index 1638a45..0000000 --- a/kubernetes-example/service.yml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: nginx-service - namespace: web-test -spec: - type: NodePort - selector: - app: nginx-deployment - ports: - # By default and for convenience, the `targetPort` is set to the same value as the `port` field. - - port: 80 - targetPort: 80 - # Optional field - # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767) - nodePort: 30007 \ No newline at end of file diff --git a/terraform/rke2-terraform/README.md b/terraform/rke2-terraform/README.md index e69de29..93cee02 100644 --- a/terraform/rke2-terraform/README.md +++ b/terraform/rke2-terraform/README.md @@ -0,0 +1,3 @@ +Deployment of RKE2 in the current OpenStack environment of NetLab @ HS-Fulda can be found here: + +[https://github.com/srieger1/terraform-openstack-rke2/tree/hsfulda-example-2023-10/examples/hs-fulda](https://github.com/srieger1/terraform-openstack-rke2/tree/hsfulda-example-2023-10/examples/hs-fulda) \ No newline at end of file