Skip to content

Latest commit

 

History

History
166 lines (127 loc) · 4.2 KB

File metadata and controls

166 lines (127 loc) · 4.2 KB

Deploy microservices on K8S

Prerequisites

To check kubectl configuration, type:

$ kubectl get nodes
NAME             STATUS   ROLES    AGE   VERSION
docker-desktop   Ready    master   10d   v1.16.6-beta.0

Deploy Kafka infrastructure

$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
$ helm install --values kafka-values.yaml kafka bitnami/kafka 
NAME: kafka
LAST DEPLOYED: Sat Jan  2 10:46:55 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
...

To verify that Kafka has been installed correctly:

$ kubectl get pods 
NAME                READY   STATUS    RESTARTS   AGE
kafka-0             1/1     Running   0          55s
kafka-zookeeper-0   1/1     Running   0          56s
...

Deploy ELK infrastructure

Add the elastic Helm repo

$ helm repo add elastic https://helm.elastic.co
"elastic" has been added to your repositories

Install Elasticsearch

$ helm install --values elasticsearch-values.yaml elasticsearch elastic/elasticsearch
NAME: elasticsearch
LAST DEPLOYED: Sat Jan  2 11:04:15 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
...

To check if Elasticsearch has been started correctly (it may take a while to get Running and Ready):

$ kubectl get pods --namespace=default -l app=elasticsearch-master   
NAME                     READY   STATUS    RESTARTS   AGE
elasticsearch-master-0   1/1     Running   0          6m43s

Install Logstash

$ helm install --values logstash-values.yaml logstash elastic/logstash
NAME: logstash
LAST DEPLOYED: Sat Jan  2 11:59:21 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
...

To check if Logstash has been started correctly (it may take a while to get Running and Ready):

$ kubectl get pods --namespace=default -l app=logstash-logstash
NAME                  READY   STATUS    RESTARTS   AGE
logstash-logstash-0   0/1     Running   0          41s

Install Filebeat as a DaemonSet

$ helm install --values filebeat-values.yaml filebeat elastic/filebeat
NAME: filebeat
LAST DEPLOYED: Sat Jan  2 12:43:53 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
...

To check if Logstash has been started correctly (it may take a while to get Running and Ready):

$ kubectl get pods --namespace=default -l app=filebeat
NAME                  READY   STATUS    RESTARTS   AGE
logstash-logstash-0   0/1     Running   0          41s

Deploy MongoDB infrastructure

Install MongoDB standalone instance for Customer microservice

$ helm install --values mongodb-values.yaml customer-mongodb bitnami/mongodb
NAME: customer-mongodb
LAST DEPLOYED: Sun Jan  3 09:08:08 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
...

To check if MongoDB has been started correctly (it may take a while to get Running and Ready):

$  kubectl get pods | grep mongo
customer-mongodb-64df6b7549-4ms2r   1/1     Running   0          100s

Deploy PostgreSQL infrastructure

Install PostgreSQL standalone instance for Order microservice

$ helm install --values postgresql-values.yaml order-postgres bitnami/postgresql
NAME: order-postgres
LAST DEPLOYED: Sun Jan  3 09:13:34 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

To check if PostgreSQL has been started correctly (it may take a while to get Running and Ready):

$  kubectl get pods | grep postgres
order-postgres-0                    1/1     Running   0          4m9s

To connect to PostgreSQL from CLI

$ kubectl run order-postgres-client --rm --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:11.10.0-debian-10-r24 --env="PGPASSWORD=postgres" --command -- psql --host order-postgres -U postgres -d postgres -p 5432