Skip to content

Latest commit

 

History

History
103 lines (74 loc) · 2.75 KB

portforwarding.md

File metadata and controls

103 lines (74 loc) · 2.75 KB

Multi k8s clusters development

Below is described how to facilitate application development in running in kubernetes.

Prerequisities

  1. Install Kubectl Client 1.13.

  2. Install Minikube.

  3. Optionally can use Skaffold project, to facilitate continuous development.

Architecture

The diagram below depicts how enable multi cluster development in k8s:

Alt text

Getting Started

Sample application that shows how to connect a frontend system with a backend in different clusters.

Remote Cluster

  1. Deploy backend application in remote cluster:
kubectl apply -f backend.yaml
  1. Make sure backend-* pod and service are up and running :
kubectl get pods,svc
NAME                          READY   STATUS    RESTARTS   AGE
pod/backend-czn64               1/1     Running   1          7d5h

NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
service/backend-srv       ClusterIP   100.70.181.149   <none>        80/TCP   7d5h
  1. Forward the backend service to localhost:
kubectl port-forward --address=192.168.99.1 $(kubectl get pod -l type=be-type -o jsonpath='{.items[0].metadata.name}') 2000:5000 &
  1. Check backend service via browser or curl:
curl http://192.168.99.1:2000/

Minikube

  1. Deploy fronted application in minikube cluster:
kubectl apply -f frontend.yaml
  1. Make sure fe-* pod and service are up and running :
kubectl get pods,svc
NAME                                            READY   STATUS    RESTARTS   AGE
pod/frontend-dlghf                                 1/1     Running   1          11h

NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
service/frontend-srv       ClusterIP   10.97.237.77     <none>        8000/TCP       11h
  1. Forward the frontend service to localhost:
kubectl port-forward $(kubectl get pod -l type=fe-type -o jsonpath='{.items[0].metadata.name}') 8000:8000 &
  1. Check frontend service is up and can forward requests to backend:
curl http://localhost:8000/

Uninstall

  1. Remove any kubectl port-forward processes that may still be running:
killall kubectl
  1. Uninstall backend application in remote cluster:
kubectl delete -f backend.yaml
  1. Deploy frontend application in minikube cluster:
kubectl delete -f frontend.yaml

References

Kubehelloworld project authored by Sal Rashid.

Authors

Opengov Devops team.