Introduction

intro

this is part 46 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.


prepare files

this part was supposed to be an aws or azure lab , but due current situation of my country (big explosion happen due chemical products) and I don't have a visa to activate free account. So I will use an Nginx server instead .

as always all the files used are in my github repo here

if you already have it just pull , if not clone it. the source code usually hold the same chapter number we are in 046 so app_046 is what we are looking for. ***

Understand files

v1

this is the app046v1.yml it's an typical deployment it use the google samples hello app. and we have service here of type clusterIp (we can use also NodePort) , this port 8080 is the default port of the hello image and the name of app is myapp-v1 and service myapp-v1 . Same for the v2 (go and take a look). What I care here about is the service because it's going to talk with the ingress. ing

we can see here annotations it's like javascript object , it's here to configure the nginx server , please go to the docs and read it. we can notice it's take a path /v1 and /v2 , and port same as the service , and name same of service name.


Lab

mad as we discuss on the # 045 when we expose our app to external ip we need Load balancer or Ingress . Ingress it's mean different routes to same hosts , example test.app.example and test2.app.example or app.example/test and app.example/test2 every route connect to an web service.

we are going to use the Ingress method in this lab. Ingress

minikube addons enable ingress

first we need to enable the ingress add on inside minikube because we are going to use nginx as server for this lab. create now let's create our deployments with name of deployments-v1 and v2.

kubectl create -f app_046_v1.yml
kubectl create -f app_046_v2.yml

pods

kubectl get pods

all our pods are created , now time to create our ingress service. ingress

kubectl create -f app_046_ingress.yml

we can see our service successfully created. geting

kubectl get ingress

now we have our ingress ready ip

minikube ip

192.168.99.100 is our local ip , if our azure setup is online we will get a real external ip that we can access any time , anywhere , and you also can access it!

services head to 192.168.99.100/v1 and 192.168.99.100/v2 the ip may vary for you so just change the ip.

we can see now we can access 2 different apps (microservices) using same ip with different routes !

This post is also available on DEV.