Create Docker Image
docker build -t iamjc321/msv01:latest .
docker login -u iamjc321 docker.io
docker push iamjc321/msv01:latest
Foundations
Create Namespace
kubectl create namespace NAME
Set Automatic Istio configurations to namespace
kubectl label namespace dev2023 istio-injection=enabled
Create
Run All
kubectl apply -f msv01.yaml -f msv02.yaml -f istio.yaml
Create a pod with curl and make a request to other pods from it
kubectl run curl-j --image=radial/busyboxplus:curl -i --tty --rm
Delete
kubectl delete deployment msv01 -n dev2023
kubectl delete svc msv01 -n dev2023
kubectl delete deployment msv02 -n dev2023
kubectl delete svc msv02 -n dev2023
kubectl delete gateway msv02
kubectl delete virtualservice msv02
kubectl label namespace dev2023 istio-injection
Get
Check services in namespace
kubectl get svc -n dev2023
Find IP of gateway
Check Istio
istioctl analyze -n dev2023
Use the following command to access the Kiali dashboard:
istioctl dashboard kiali
Get logs
kubectl logs deployment/<name-of-deployment> # logs of deployment
kubectl logs -f deployment/msv01 -n dev2023
Operations
Run commands in running pod
kubectl exec --stdin --tty msv01-5cfb69ffdb-wqchx -n dev2023 -- ls /
kubectl exec --stdin --tty msv02-6cc57f9f78-hqh9h -n dev2023 -- wget localhost:8081/portfolio/
Run Curl
kubectl run curl-j --image=radial/busyboxplus:curl -i --tty --rm
Make a call from ingress
#Get IP Address of Gateway
kubectl get svc istio-ingressgateway -n istio-system
#Use IP to make call to internal service, <gateway-ip>:<gateway-port>/<kub-service>/<endpoint>
curl http://10.43.108.251:80/search/iscall
Example
Spring Service
apiVersion: apps/v1
kind: Deployment
metadata:
name: msv01
namespace: dev2023
spec:
replicas: 1
selector:
matchLabels:
app: msv01
template:
metadata:
labels:
app: msv01
spec:
containers:
- name: msv01
image: iamjc321/msv01:1.0.4
imagePullPolicy: Always
ports:
- containerPort: 8081
env:
- name: PORTFOLIO_URL
value: http://msv02:8081/portfolio
---
apiVersion: v1
kind: Service
metadata:
name: msv01
namespace: dev2023
spec:
ports:
- port: 8082
targetPort: 8082
protocol: TCP
name: http
selector:
app: msv01