Skip to content

Commit 42f7b97

Browse files
authored
feat(docs): use helm 3 and other minor fixes (#8)
1 parent cc6d39e commit 42f7b97

File tree

3 files changed

+23
-107
lines changed

3 files changed

+23
-107
lines changed

README.md

Lines changed: 19 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ The tutorial of "how to create a cluster" is based of this [bitnami tutorial](ht
1010

1111
# The project
1212
- **chat_front:** Is a simple webpage that sends and receives messages from chat_svc through socket io
13-
When you finish this tutorial, you can see this Microservice in 127.0.0.1.nip.io
1413
- **chat_svc:** Receives messages from chat_front and sends these messages to chat_db to store this information
15-
When you finish this tutorial, you can see this Microservice in svc.127.0.0.1.nip.io
1614
- **chat_db:** Receives data from chat_svc and stores this information in a SQLite DB.
1715

1816
## Architecture
@@ -39,6 +37,8 @@ Install Minikube in your local system, either by using a virtualization software
3937
curl -Lo minikube https://storage.googleapis.com/minikube/releases/vX.Y.Z/minikube-OS_DISTRIBUTION-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
4038
```
4139

40+
TIP: If you use homebrew you can install it with the brew install command: `brew install minikube`.
41+
4242
## Step 2: Create A Kubernetes Cluster
4343
By starting Minikube, a single-node cluster is created. Run the following command in your terminal to complete the creation of the cluster:
4444

@@ -47,20 +47,19 @@ minikube start
4747
```
4848

4949

50-
Install ingress
50+
Install ingress:
5151

5252
```
5353
minikube addons enable ingress
5454
```
5555

56-
Set the environment of docker
56+
Set the environment of docker. This will make you shell use minikube's docker, so any image you build, you'll build it in the minikube machine. With this, you won't need a docker registry:
5757
```bash
5858
eval $(minikube docker-env)
5959
```
6060

6161
To run your commands against Kubernetes clusters, the kubectl CLI is needed. Check step 3 to complete the installation of kubectl.
6262

63-
6463
## Step 3: Install The Kubectl Command-Line Tool
6564
In order to start working on a Kubernetes cluster, it is necessary to install the Kubernetes command line (kubectl). Follow these steps to install the kubectl CLI:
6665

@@ -74,7 +73,7 @@ In order to start working on a Kubernetes cluster, it is necessary to install th
7473

7574
TIP: Once the kubectl CLI is installed, you can obtain information about the current version with the kubectl version command.
7675

77-
NOTE: You can also install kubectl by using the sudo apt-get install kubectl command.
76+
NOTE: You can also install kubectl by using the `sudo apt-get install kubectl` command. If you use homebrew you can install it with the brew install command: `brew install kubectl`.
7877

7978
* Check that kubectl is correctly installed and configured by running the kubectl cluster-info command:
8079

@@ -101,11 +100,10 @@ In order to start working on a Kubernetes cluster, it is necessary to install th
101100
```
102101
![Check Kubernetes node info](https://docs.bitnami.com/images/img/platforms/kubernetes/k8-tutorial-33.png)
103102

104-
105103
[Learn more about the kubectl CLI](https://kubernetes.io/docs/user-guide/kubectl-overview/).
106104

107-
## Step 4: Install And Configure Helm And Tiller
108-
The easiest way to run and manage applications in a Kubernetes cluster is using Helm. Helm allows you to perform key operations for managing applications such as install, upgrade or delete. Helm is composed of two parts: Helm (the client) and Tiller (the server). Follow the steps below to complete both Helm and Tiller installation and create the necessary Kubernetes objects to make Helm work with Role-Based Access Control (RBAC):
105+
## Step 4: Install Helm
106+
The easiest way to run and manage applications in a Kubernetes cluster is using Helm. Helm allows you to perform key operations for managing applications such as install, upgrade or delete.
109107

110108
* To install Helm, run the following commands:
111109

@@ -115,61 +113,7 @@ The easiest way to run and manage applications in a Kubernetes cluster is using
115113
./get_helm.sh
116114
```
117115

118-
TIP: If you are using OS X you can install it with the brew install command: brew install kubernetes-helm.
119-
120-
* Create a ClusterRole configuration file with the content below. In this example, it is named clusterrole.yaml.
121-
122-
```yaml
123-
apiVersion: rbac.authorization.k8s.io/v1
124-
kind: ClusterRole
125-
metadata:
126-
annotations:
127-
rbac.authorization.kubernetes.io/autoupdate: "true"
128-
labels:
129-
kubernetes.io/bootstrapping: rbac-defaults
130-
name: cluster-admin
131-
rules:
132-
- apiGroups:
133-
- '*'
134-
resources:
135-
- '*'
136-
verbs:
137-
- '*'
138-
- nonResourceURLs:
139-
- '*'
140-
verbs:
141-
- '*'
142-
```
143-
144-
* To create the ClusterRole, run this command:
145-
146-
```bash
147-
kubectl create -f clusterrole.yaml
148-
```
149-
150-
* To create a ServiceAccount and associate it with the ClusterRole, use a ClusterRoleBinding, as below:
151-
152-
```bash
153-
kubectl create serviceaccount -n kube-system tiller
154-
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
155-
```
156-
157-
* Initialize Helm as shown below:
158-
159-
```bash
160-
helm init --service-account tiller
161-
```
162-
If you have previously initialized Helm, execute the following command to upgrade it:
163-
164-
```bash
165-
helm init --upgrade --service-account tiller
166-
```
167-
* Check if Tiller is correctly installed by checking the output of kubectl get pods as shown below:
168-
169-
```bash
170-
kubectl --namespace kube-system get pods | grep tiller
171-
tiller-deploy-2885612843-xrj5m 1/1 Running 0 4d
172-
```
116+
TIP: If you use homebrew you can install it with the brew install command: `brew install kubernetes-helm`.
173117

174118
Once you have installed Helm, a set of useful commands to perform common actions is shown below:
175119

@@ -188,17 +132,21 @@ Create the docker images:
188132
Check your helm charts:
189133

190134
```bash
191-
helm install --dry-run --debug ./chat_db/chat_db/
192-
helm install --dry-run --debug ./chat_svc/chat_svc/
193-
helm install --dry-run --debug ./chat_front/chat_front/
135+
helm upgrade --dry-run --install chat-front ./chat_front/chat_front/ \
136+
--set ingress.enabled=true --set "ingress.hosts[0]=$(minikube ip).nip.io"
137+
helm upgrade --dry-run --install chat-svc ./chat_svc/chat_svc/ --set \
138+
--set ingress.enabled=true --set "ingress.hosts[0]=svc.$(minikube ip).nip.io"
139+
helm upgrade --dry-run --install chat-db ./chat_db/chat_db/
194140
```
195141

196142
Install helm charts:
197143

198144
```bash
199-
helm install --name chat-db ./chat_db/chat_db/
200-
helm install --name chat-svc ./chat_svc/chat_svc/
201-
helm install --name chat-front ./chat_front/chat_front/
145+
helm upgrade --install chat-front ./chat_front/chat_front/ \
146+
--set ingress.enabled=true --set "ingress.hosts[0]=$(minikube ip).nip.io"
147+
helm upgrade --install chat-svc ./chat_svc/chat_svc/ --set \
148+
--set ingress.enabled=true --set "ingress.hosts[0]=svc.$(minikube ip).nip.io"
149+
helm upgrade --install chat-db ./chat_db/chat_db/
202150
```
203151

204152
## Step 6
@@ -213,33 +161,6 @@ Verify that all pods are Ok:
213161

214162
## Step 7
215163

216-
Open http://127.0.0.1.nip.io/ and see the magic! ;)
164+
Open the IP that the command `minikube ip` returns and see the magic! ;)
217165

218166
![](docs/imgs/front_ms.png)
219-
220-
221-
## Troubleshooting
222-
223-
If this URL doesn't work, maybe you need to install a nginx and redirect the traffic from 127.0.0.1 to the minikube IP,
224-
for example, you can use nginx.
225-
226-
### Way 1: Get your cluster with minikube
227-
Check your Minikube IP with:
228-
```
229-
minikube ip
230-
```
231-
232-
### Way 2: Get your cluster with kubectl
233-
234-
```
235-
kubectl cluster-info
236-
```
237-
![](docs/imgs/kubectl_get_ip.png)
238-
239-
### Add your cluster IP to nginx
240-
241-
- Edit your nginx config with this code as example: See [this example](nginx_example_conf)
242-
```
243-
vim /etc/nginx/sites-enabled/default
244-
```
245-

chat_front/chat_front/values.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ service:
1717
port: 80
1818

1919
ingress:
20-
enabled: true
20+
enabled: false
2121
annotations: {}
2222
# kubernetes.io/ingress.class: nginx
2323
# kubernetes.io/tls-acme: "true"
2424
paths: ["/"]
25-
hosts:
26-
- 127.0.0.1.nip.io
27-
- 192.168.99.100.nip.io
28-
- 192.168.49.2.nip.io
25+
hosts: []
2926
tls: []
3027
# - secretName: chart-example-tls
3128
# hosts:

chat_svc/chat_svc/values.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ service:
1717
port: 80
1818

1919
ingress:
20-
enabled: true
20+
enabled: false
2121
annotations: {}
2222
# kubernetes.io/ingress.class: nginx
2323
# kubernetes.io/tls-acme: "true"
2424
paths: ["/"]
25-
hosts:
26-
- svc.127.0.0.1.nip.io
27-
- svc.192.168.49.2.nip.io
25+
hosts: []
2826
tls: []
2927
# - secretName: chart-example-tls
3028
# hosts:

0 commit comments

Comments
 (0)