From c8fa3f17d0d007f902ce1ab462caace465000449 Mon Sep 17 00:00:00 2001 From: medusa Date: Tue, 25 Jun 2024 06:23:40 +0000 Subject: [PATCH] Update tech_docs/minikube_setup_debian.md --- tech_docs/minikube_setup_debian.md | 128 +++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/tech_docs/minikube_setup_debian.md b/tech_docs/minikube_setup_debian.md index 6867a78..66daa1c 100644 --- a/tech_docs/minikube_setup_debian.md +++ b/tech_docs/minikube_setup_debian.md @@ -1,3 +1,131 @@ +Certainly! Let's deploy a more useful sample application—a simple web application that uses Nginx as a web server and serves a static HTML page. This example will cover the creation of a deployment, a service, and accessing the application. + +### Step 1: Create a Deployment YAML File + +1. Create a file named `nginx-deployment.yaml` with the following content: + + ```yaml + apiVersion: apps/v1 + kind: Deployment + metadata: + name: nginx-deployment + spec: + replicas: 3 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.21.6 + ports: + - containerPort: 80 + volumeMounts: + - name: html + mountPath: /usr/share/nginx/html + volumes: + - name: html + configMap: + name: html-configmap + ``` + +### Step 2: Create a ConfigMap for the HTML Page + +2. Create a file named `html-configmap.yaml` with the following content: + + ```yaml + apiVersion: v1 + kind: ConfigMap + metadata: + name: html-configmap + data: + index.html: | + + + + Welcome to Nginx + + +

Welcome to your Nginx application!

+

Deployed with Minikube on Kubernetes.

+ + + ``` + +### Step 3: Create a Service YAML File + +3. Create a file named `nginx-service.yaml` with the following content: + + ```yaml + apiVersion: v1 + kind: Service + metadata: + name: nginx-service + spec: + type: NodePort + selector: + app: nginx + ports: + - protocol: TCP + port: 80 + targetPort: 80 + nodePort: 30007 + ``` + +### Step 4: Deploy the Application + +4. Apply the ConfigMap: + + ```sh + kubectl apply -f html-configmap.yaml + ``` + +5. Apply the Deployment: + + ```sh + kubectl apply -f nginx-deployment.yaml + ``` + +6. Apply the Service: + + ```sh + kubectl apply -f nginx-service.yaml + ``` + +### Step 5: Access the Application + +1. Check the status of the pods to ensure they are running: + + ```sh + kubectl get pods + ``` + +2. Get the URL for the Nginx service: + + ```sh + minikube service nginx-service --url + ``` + +3. Open the URL in your web browser. You should see the static HTML page served by Nginx. + +### Step 6: Clean Up + +1. To delete the resources, you can run: + + ```sh + kubectl delete -f nginx-service.yaml + kubectl delete -f nginx-deployment.yaml + kubectl delete -f html-configmap.yaml + ``` + +This setup will provide you with a more useful and practical application deployment scenario, giving you a better understanding of how to work with Kubernetes deployments, services, and ConfigMaps. + +--- + Here's a step-by-step guide to set up Minikube on your Debian 12 system for a complete Kubernetes learning lab: ### Prerequisites