Skip to content

Commit

Permalink
add kubenetes instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
tslmy committed Dec 28, 2020
1 parent b817c76 commit 47ddab2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ docker run -p 80:80 --rm --name ttt-demo ttt

... or via Docker Compose: `docker-compose up`.

### Via Kubernetes

I will be using [minikube](https://minikube.sigs.k8s.io/) in this walkthrough. I will be using the local Docker Registry as the source of the Kubenetes image.

```shell
# Start the cluster:
minikube start
# Register the Docker Registry to minikube -- This is because we will be building the image from the Dockerfile for Kubenetes:
eval $(minikube docker-env)
# Build the Docker image for Kubenetes:
docker build -t ttt .
# Apply the Deployment (which manages the Pods/"virtual hosts" in the minikube cluster for the app) as well as the Service (which is a Load Balancer in this case that exposes the web app in the Pods) using the manifest file:
kubectl apply -f kubernetes-manifest.yml
# Access the web app:
minikube service ttt-demo-service
```

## Usage

To post a new article, simply upload your `txt` file to `content/`.
Expand Down
32 changes: 32 additions & 0 deletions kubernetes-manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ttt-demo-deployment
spec:
selector:
matchLabels:
run: ttt-demo # This selects the Pod Template defined below.
replicas: 2 # num of pods matching the template
template:
metadata:
labels:
run: ttt-demo # This labels/identifies this template as "run: ttt-demo".
spec:
containers:
- name: ttt-container
image: ttt:latest
imagePullPolicy: Never # required since we are using a local Docker registry
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: ttt-demo-service
spec:
selector:
run: ttt-demo # This selects the pods defined in the Deployment above.
type: LoadBalancer
ports:
- port: 80
targetPort: 80

0 comments on commit 47ddab2

Please sign in to comment.