Micro-services – Expert Network Consultant https://www.expertnetworkconsultant.com Networking | Cloud | DevOps | IaC Thu, 23 Sep 2021 01:32:01 +0000 en-GB hourly 1 https://wordpress.org/?v=6.3.2 How to Create Azure AKS Cluster https://www.expertnetworkconsultant.com/cloud/how-to-create-azure-aks-cluster/ Wed, 22 Sep 2021 23:00:28 +0000 http://www.expertnetworkconsultant.com/?p=4667 Continue readingHow to Create Azure AKS Cluster]]> How to Create AKS Cluster

Kubernetes has come to change the world of Microservices. Azure makes Kubernetes Orchestration a breeze with their Azure Kubernetes Services. In this step by step tutorial, I show you how to create your first Kubernetes Cluster on Azure. Before we proceed, may I indulge you with a post I created a little while ago on Azure Networking?

Step 1: create an azure kubernetes service resource on azure
create an azure kubernetes service resource on azure

Step 2: create an azure kubernetes service cluster
create an azure kubernetes service cluster

Step 3: create a kubernetes cluster
create a kubernetes cluster

Step 3: create a kubernetes cluster specify resource group
create a kubernetes cluster specify resource group

Step 4: create a kubernetes cluster name
create a kubernetes cluster name

Step 5: create a kubernetes cluster kubernetes version
create a kubernetes cluster kubernetes version

Step 6: create a kubernetes cluster choose a vm size
create a kubernetes cluster choose a vm size

Step 7: create a kubernetes cluster enable virtual machine scale sets
create a kubernetes cluster enable virtual machine scale sets

Step 8: create a kubernetes cluster – validation passed
create a kubernetes cluster - validation passed

Step 9: create a kubernetes cluster – deployment
create a kubernetes cluster - deployment

Step 10: create a kubernetes cluster – deployment complete
create a kubernetes cluster - deployment complete

How to Create AKS Cluster – Working via the Shell

Connect to your cluster using command line tooling to interact directly with cluster using kubectl, the command line tool for Kubernetes. Kubectl is available within the Azure Cloud Shell by default and can also be installed locally

az account set --subscription 938f58d6-a922-40d0-b7b2-7068c5392eaf 

az aks get-credentials --resource-group learn-503b25e2-82da-40c1-a257-35aeaa9614ae --name aks-workload-westus

# List all deployments in all namespaces


kubectl get --all-namespaces


kubectl get deployments --all-namespaces=true

kubectl get deployments --namespace kube-system

# List all deployments in a specific namespace
# Format :kubectl get deployments –namespace


kubectl get deployments --namespace kube-system

# List details about a specific deployment
# Format :kubectl describe deployment –namespace


kubectl describe deployment my-dep --namespace kube-system

# List pods using a specific label
# Format :kubectl get pods -l = –all-namespaces=true


kubectl get pods -l app=nginx --all-namespaces=true

# Get logs for all pods with a specific label
# Format :kubectl logs -l =


kubectl logs -l app=nginx --namespace kube-system

With your AKS Cluster now deployed, kubernetes commands can now be issued.


azure_portal@Azure:~$ kubectl get pods -n kube-system
NAME                                  READY   STATUS    RESTARTS   AGE
azure-ip-masq-agent-cfz8r             1/1     Running   0          53m
coredns-autoscaler-54d55c8b75-d7xjm   1/1     Running   0          54m
coredns-d4866bcb7-4wzr8               1/1     Running   0          54m
coredns-d4866bcb7-n4jf8               1/1     Running   0          53m
kube-proxy-5xpvw                      1/1     Running   0          53m
metrics-server-569f6547dd-k5l97       1/1     Running   0          54m
tunnelfront-9bfd7cd94-9hh2c           1/1     Running   0          54m
azure_portal@Azure:~$

azure_portal@Azure:~$ kubectl get nodes
NAME                                STATUS   ROLES   AGE   VERSION
aks-agentpool-29375834-vmss000001   Ready    agent   55m   v1.20.9

azure_portal@Azure:~$ kubectl get all
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.0.0.1             443/TCP   57m

azure_portal@Azure:~$ kubectl get deployments -n kube-system
NAME                 READY   UP-TO-DATE   AVAILABLE   AGE
coredns              2/2     2            2           57m
coredns-autoscaler   1/1     1            1           57m
metrics-server       1/1     1            1           57m
tunnelfront          1/1     1            1           57m
azure_portal@Azure:~$

azure_portal@Azure:~$ kubectl get rs  -n kube-system
NAME                            DESIRED   CURRENT   READY   AGE
coredns-autoscaler-54d55c8b75   1         1         1       58m
coredns-d4866bcb7               2         2         2       58m
metrics-server-569f6547dd       1         1         1       58m
tunnelfront-9bfd7cd94           1         1         1       58m

azure_portal@Azure:~$ kubectl get cm  -n kube-system
NAME                                 DATA   AGE
azure-ip-masq-agent-config           1      59m
cluster-autoscaler-status            1      59m
coredns                              1      59m
coredns-autoscaler                   1      58m
coredns-custom                       0      59m
extension-apiserver-authentication   6      59m
kube-root-ca.crt                     1      59m
overlay-upgrade-data                 4      59m
tunnelfront-kubecfg                  1      59m
azure_portal@Azure:~$

Follow Microsoft’s Lab on creating Azure Kubernetes Services here.

]]>
Docker Communication Between Containers https://www.expertnetworkconsultant.com/design/docker-communication-between-containers/ Wed, 23 Sep 2020 12:00:15 +0000 http://www.expertnetworkconsultant.com/?p=3982 Continue readingDocker Communication Between Containers]]> Docker Communication Between Containers

If you want to be able to ping or basically access a running docker container from another container by simply using the docker name rather than an IP address, DNS must work well. Docker natively provides DNS capability to get containers in the same network to communicate between containers over their DNS names as IP addressing changes as containers go in and out.

Basics of Docker Networking;

Docker Network Defaults;
Each container connected to a private virtual network “bridge”
Each virtual network routes through NAT firewall on host IP
All containers on a virtual network can talk to each other without -p

Docker Network Best Practices;
Create a new virtual network for each app:

  • network “web_app_network” for mysql and php or apache containers
  • network “web_api_network” for mongo and nodejs containers
  • Step 1:
    Let us begin by creating two containers; I am using the NGINX Image.

    You can download the nginx to the Local Cache.

    $>docker image ls 
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    httpd               latest              417af7dc28bc        7 days ago          138MB
    nginx               latest              7e4d58f0e5f3        12 days ago         133MB
    mysql               latest              e1d7dc9731da        13 days ago         544MB
    alpine              latest              a24bb4013296        3 months ago        5.57MB
    

    Get the image by typing “docker container pull nginx”

    docker container run -d --name container1  -p 8080:80 nginx
    docker container run -d --name container2  -p 8088:80 nginx
    

    Let us verify

    $docker container ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                  NAMES
    a1147ca12e97        nginx               "/docker-entrypoint.…"   1 hours ago          Up 10 minutes       0.0.0.0:8080->80/tcp   container1
    0e364de8f313        nginx               "/docker-entrypoint.…"   1 hours ago          Up 10 minutes       0.0.0.0:8088->80/tcp   container2
    

    docker communication between containers

    Important note: it is of utmost importance to explicitly specify a name with –name for your containers. The reason being that it will not work with the auto-generated names that Docker assigns to your container(s).

    Step 2:
    Create a new network:

    docker network create nginx-network

    Verify if this network is listed in the docker networks

    C:\>docker network ls
    NETWORK ID          NAME                DRIVER              SCOPE
    25d4ec1592eb        bridge              bridge              local
    ba0017e88f28        host                host                local
    06658aee8f0c        nginx-network       bridge              local
    70be58caf984        none                null                local
    33668dd3b17f        webservices         bridge              local
    

    Step 3:
    Connect your containers to the network:

    docker network connect nginx-network container1
    docker network connect nginx-network container2
    

    Step 4:
    Verify if your containers are part of the newly created network (nginx-network):

    docker network inspect nginx-network
    
      "ConfigOnly": false,
            "Containers": {
                "0e364de8f3134e242e513a6cf3da4b69bb38fb7ef17213a309a7bda27b423b3a": {
                    "Name": "container1",
                    "EndpointID": "fdf973b2840adea185bec76c8684bb1c404a21ccb9947c16c58119b350aebb36",
                    "MacAddress": "02:42:ac:12:00:03",
                    "IPv4Address": "172.18.0.3/16",
                    "IPv6Address": ""
                },
                "a1147ca12e97cb054af40ab67255d9dd5817d7197695e3756ee5fd614195de77": {
                    "Name": "container2",
                    "EndpointID": "6edb537acdc3b1ec6ee233993d9e6d28cd8a62055600300d0e77e48c94ee9a88",
                    "MacAddress": "02:42:ac:12:00:02",
                    "IPv4Address": "172.18.0.2/16",
                    "IPv6Address": ""
                }
    

    Install ping for nginx as not all images come prepackaged with the ping utility

    Run docker container1 and install ping. you can do so by going to the bash of the container by typing;

    These two commands are needed. You can go ahead line by line as per below or in one single line as per the instruction 2 below;

    Instruction 1:

     
    apt-get update
    apt-get install iputils-ping
    

    Instruction 2:

    $docker container exec -it container1 bash
    root@a1147ca12e97:/#
    root@a1147ca12e97:/# apt-get update && apt-get install iputils-ping
    

    Repeat above step for container2

    Final Step:
    Finally test the connection between container1 and container2.

    $docker container exec -it container1 ping container2
    PING container2 (172.18.0.3) 56(84) bytes of data.
    64 bytes from container2.nginx-network (172.18.0.3): icmp_seq=1 ttl=64 time=0.050 ms
    64 bytes from container2.nginx-network (172.18.0.3): icmp_seq=2 ttl=64 time=0.043 ms
    64 bytes from container2.nginx-network (172.18.0.3): icmp_seq=3 ttl=64 time=0.142 ms
    64 bytes from container2.nginx-network (172.18.0.3): icmp_seq=4 ttl=64 time=0.145 ms
    64 bytes from container2.nginx-network (172.18.0.3): icmp_seq=5 ttl=64 time=0.142 ms
    64 bytes from container2.nginx-network (172.18.0.3): icmp_seq=6 ttl=64 time=0.066 ms
    64 bytes from container2.nginx-network (172.18.0.3): icmp_seq=7 ttl=64 time=0.047 ms
    ^C
    --- container2 ping statistics ---
    7 packets transmitted, 7 received, 0% packet loss, time 129ms
    rtt min/avg/max/mdev = 0.043/0.090/0.145/0.047 ms
    

    Hope you have enjoyed this article? Look out for more on this website. Bookmark by pressing (CTRL + D)

    Follow this link to learn more about the amazing nginx docker image.

    ]]>