Update tech_docs/minikube_setup_debian.md
This commit is contained in:
@@ -1,3 +1,233 @@
|
||||
A good reference project for learning how to work with Kubernetes (K8s) should cover various aspects of K8s, including deployments, services, networking, storage, and scaling. One such project is the **"Guestbook"** application, a simple multi-tier web application that demonstrates many core concepts of Kubernetes.
|
||||
|
||||
### Guestbook Application Overview
|
||||
|
||||
The Guestbook application consists of the following components:
|
||||
|
||||
1. **Frontend**: A PHP-based web interface that users can interact with.
|
||||
2. **Backend**: A Redis master and a set of Redis replicas that store the guestbook entries.
|
||||
|
||||
### Step-by-Step Guide to Deploy the Guestbook Application
|
||||
|
||||
#### Step 1: Clone the Kubernetes Examples Repository
|
||||
|
||||
First, clone the Kubernetes examples repository to get the configuration files for the Guestbook application.
|
||||
|
||||
```sh
|
||||
git clone https://github.com/kubernetes/examples.git
|
||||
cd examples/guestbook
|
||||
```
|
||||
|
||||
#### Step 2: Deploy the Redis Master
|
||||
|
||||
1. Create a Redis Master Deployment:
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: redis-master
|
||||
labels:
|
||||
app: redis
|
||||
tier: backend
|
||||
role: master
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: redis
|
||||
role: master
|
||||
tier: backend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
role: master
|
||||
tier: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: master
|
||||
image: redis
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
```
|
||||
|
||||
2. Create a Redis Master Service:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-master
|
||||
labels:
|
||||
app: redis
|
||||
tier: backend
|
||||
role: master
|
||||
spec:
|
||||
ports:
|
||||
- port: 6379
|
||||
selector:
|
||||
app: redis
|
||||
role: master
|
||||
tier: backend
|
||||
```
|
||||
|
||||
Apply these configurations:
|
||||
|
||||
```sh
|
||||
kubectl apply -f redis-master-deployment.yaml
|
||||
kubectl apply -f redis-master-service.yaml
|
||||
```
|
||||
|
||||
#### Step 3: Deploy the Redis Replicas
|
||||
|
||||
1. Create a Redis Replica Deployment:
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: redis-slave
|
||||
labels:
|
||||
app: redis
|
||||
tier: backend
|
||||
role: slave
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: slave
|
||||
image: gcr.io/google_samples/gb-redisslave:v3
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
env:
|
||||
- name: GET_HOSTS_FROM
|
||||
value: dns
|
||||
```
|
||||
|
||||
2. Create a Redis Replica Service:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-slave
|
||||
labels:
|
||||
app: redis
|
||||
tier: backend
|
||||
role: slave
|
||||
spec:
|
||||
ports:
|
||||
- port: 6379
|
||||
selector:
|
||||
app: redis
|
||||
role: slave
|
||||
tier: backend
|
||||
```
|
||||
|
||||
Apply these configurations:
|
||||
|
||||
```sh
|
||||
kubectl apply -f redis-slave-deployment.yaml
|
||||
kubectl apply -f redis-slave-service.yaml
|
||||
```
|
||||
|
||||
#### Step 4: Deploy the Guestbook Frontend
|
||||
|
||||
1. Create a Frontend Deployment:
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: guestbook
|
||||
labels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: php-redis
|
||||
image: gcr.io/google-samples/gb-frontend:v4
|
||||
ports:
|
||||
- containerPort: 80
|
||||
```
|
||||
|
||||
2. Create a Frontend Service:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: frontend
|
||||
labels:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
app: guestbook
|
||||
tier: frontend
|
||||
```
|
||||
|
||||
Apply these configurations:
|
||||
|
||||
```sh
|
||||
kubectl apply -f frontend-deployment.yaml
|
||||
kubectl apply -f frontend-service.yaml
|
||||
```
|
||||
|
||||
#### Step 5: Verify and Access the Application
|
||||
|
||||
1. Check the status of all deployments and services:
|
||||
|
||||
```sh
|
||||
kubectl get deployments
|
||||
kubectl get services
|
||||
```
|
||||
|
||||
2. Access the frontend service using the Minikube service URL:
|
||||
|
||||
```sh
|
||||
minikube service frontend
|
||||
```
|
||||
|
||||
This will open the Guestbook application in your web browser.
|
||||
|
||||
### Additional Learning Resources
|
||||
|
||||
1. **Kubernetes Documentation**: The official [Kubernetes documentation](https://kubernetes.io/docs/home/) is a comprehensive resource.
|
||||
2. **Katacoda Scenarios**: Interactive Kubernetes tutorials on [Katacoda](https://www.katacoda.com/courses/kubernetes).
|
||||
3. **Kubernetes Up and Running**: A great book by Kelsey Hightower, Brendan Burns, and Joe Beda.
|
||||
4. **Kubernetes the Hard Way**: A tutorial by Kelsey Hightower on [GitHub](https://github.com/kelseyhightower/kubernetes-the-hard-way).
|
||||
|
||||
This project will give you hands-on experience with deployments, services, scaling, and more, making it an excellent reference for learning Kubernetes.
|
||||
|
||||
---
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user