This use case shows how to facilitate local development with services running in remote cluster.
-
Install latest Kubectl client.
-
Install latest Docker.
-
Install latest Telepresence.
-
Install latest Minikube.
-
Install latest Go language.
The diagram below depicts how to enable multi cluster development in k8s:
Sample application that shows how to connect a frontend in development with a production backend run in remote cluster.
- Deploy backend and frontend applications in remote cluster:
kubectl apply -f backend.yaml,frontend.yaml
- Make sure fe-, be- pods and services are up and running :
kubectl get pods,svc
NAME READY STATUS RESTARTS AGE
pod/backend-5cbcdfd67b-x2sbs 1/1 Running 0 23m
pod/frontend-7b77896f9b-5rnhc 1/1 Running 0 102s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/be-srv ClusterIP 100.68.217.68 <none> 80/TCP 23m
service/fe-srv ClusterIP 100.70.86.99 <none> 80/TCP 4m10s
- Create new service in remote cluster and forward to local server:
telepresence --swap-deployment frontend --namespace default --run-shell
python3 -m http.server 8000
OR:
telepresence --swap-deployment frontend --namespace default --expose 8000 \
--run python3 -m http.server 8000
- Make sure a new helloworld deployment created:
kubectl get pods,svc -n default
NAME READY STATUS RESTARTS AGE
hello-world-5b976dc979-zk7qv 1/1 Running 0 9s
Note: To stop telepresence, please type 'exit' in terminal, which will automatically delete telepresence deployment from remote cluster.
- In another terminal, make sure can reach from backend services running in remote cluster to newly created hello-world service in localhost:
curl http://hello-world:9000
Hello, world!
python3 helloworld.py
127.0.0.1 - - [02/Nov/2018 13:17:17] "GET / HTTP/1.1" 200 -
- Uninstall backend application in remote cluster:
kubectl delete -f backend.yaml,frontend.yaml
- To stop Telepresence, type 'exit' or CTRL-D in terminal telepresence is active.
Kubehelloworld project authored by Sal Rashid.
Opengov Devops team.