Covered
- Docker
- Kubernates
- Event Bus using RabbitMQ
- gRPC
Pending
- Service discovery
- Handle Null connection
Execution
- Build image from the folder with dockerfile :
docker build -t nayan112/platformservice .
- Run the image: (disabled https redirection & swagger is enabled in dev only)
docker run -p 8080:80 -d nayan112/platformservice
- push the image :
docker push nayan112/platformservice
- Check id kubernetis is running with version:
kubectl version
- Navigate to the folder K8S and deploy platform service & related cluster ip:
kubectl apply -f platforms-deployment.yaml
- Check deployments: (need to push the image to docker hub first if missed)
kubectl get deployments
kubectl get pods
- delete deployment related to platform service:
kubectl delete deployment platform-deployment
- Start services to enable access through node port:
kubectl apply -f platforms-np-srv.yaml
- Check services:
kubectl get services
- Get the external port of nodeport to connect to the pod
- Refresh deployment/docker image:
kubectl rollout restart deployment <depoyment_name>
- To view pods running from all namespaces: (default is application namespace):
kubectl get namespaces
kubectl get deployments --namespace=ingress-nginx
kubectl get services --namespace=ingress-nginx
- Configuration of Ingress Nginx container & Ingress Nginx load balancer:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.2/deploy/static/provider/cloud/deploy.yaml
- Deploy ingress service so that application can be accessed from outside:
kubectl apply -f ingress-srv.yaml
- Ingress service needs a host name. Localhost doesn't work. So create an entry in host file similar to hostname in deployment file.
- Create persistent view claim for MSSQL:
kubectl apply -f local-pvc.yaml
- Verify the claim:
kubectl get pvc
kubectl get storageclass
- Create a secret for db password:
kubectl create secret generic mssql --from-literal=SA_PASSWORD="r00t.R00T"
- Deploy mssql: check status with pods & deployments (ImagePullBackOff is a common error)
kubectl apply -f mssql-platform-deployment.yaml
- Setup of DB migration (not part of execution): run ef migration. Need to disable in memory db & set db connection string)
dotnet ef migrations add initialmigration
- Deploy rabbitmq queue manager & management portal, load balancer & cluster ip: (verify at http://localhost:15672)
kubectl apply -f rabbitmq-deployment.yaml
- gRPC setup done without https, needed in the server (platformservice) -- check kestrel config in prod configs
Help
- Editing code in VSCode: Navigate to the particular project and type
code -r <foldername>
- Formatting in VS CODE :
Alt + Shift + F
Errors
- Swagger fails to load : Fix: decoreate api methods with REST method decorators, HTTPGET, HTTPPUT
- GetPlatformById method doesnt hit breakpoint/Swagger doesn't hit the method: Duplicate method if query string is not recognized. Set decorator as HTTPGET("Id=id")
- Converting YAML to JSON: yaml: line 4: found character that cannot start any token: Yaml is CRAZY.. use spaces instead of tab
- NodePort not working: Verify name in selector-> app & service deployment file (eg. in platforms-deployment.yaml & platforms-np-srv.yaml)
- http port is not accessible: System restart or try changing the port no.
- ImagePullBackOff : no network, no image, wrong image path
- mssql image deployment error: port 1433 in host machine in use, password policy not in complience
Enabling & using local dashboard: Remote- coming..
- Deploy dashboard:
kubectl apply -f dashboard.yaml
- Deploy an admin user:
kubectl apply -f dashboard-adminuser.yaml
- Get the token:
kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"
- Run the dashboard proxy:
kubectl proxy
- Application is available Application
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
- Remove the admin ServiceAccount and ClusterRoleBinding.
kubectl -n kubernetes-dashboard delete serviceaccount admin-user
kubectl -n kubernetes-dashboard delete clusterrolebinding admin-user
Video link
https://www.youtube.com/watch?v=DgVjEo3OGBI