Update tech_docs/minikube_setup_debian.md

This commit is contained in:
2024-06-25 06:23:40 +00:00
parent 9961262b61
commit c8fa3f17d0

View File

@@ -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: |
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Nginx</title>
</head>
<body>
<h1>Welcome to your Nginx application!</h1>
<p>Deployed with Minikube on Kubernetes.</p>
</body>
</html>
```
### 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