Main Note
https://docs.google.com/document/d/1mcjdlduwsKzc6dTi4p75fArpz7CQY8kQ67G1t2ndMQI/edit
create service for database
route :: [Kubernetes] --> [workload] --> my-database-02 --> click "expose"
port mapping 3006 : 3006
service type Cluster API
service name my-database-02
create service for backend
route :: [Kubernetes] --> [workload] --> my-backend-02 --> click "expose"
port mapping 3000 : 3000
service type load balancer
service name my-backend-02
After changing project files, re-build and re-push
docker compose -f docker-compose.prod.yaml build
docker compose -f docker-compose.prod.yaml push
route :: [Kubernetes Engine] --> [Cluster] --> autopilot-cluster-02-1 --> {connect} --> [[ run in cloud shell ]]
(View all the pods that are currently working) >> kubectl get pod
(View deployment name) >> kubectl get deployment
kubectl set image deployment/my-backend-02 my-backend-02-256-1=my-backend-02-32524f342f]
kubectl set image deployment/[Operating deployment name] [Deployed image name]=[Image that is uploaded to cotainer registry]
β€ If this command is written, you don't have to deploy again every single time anymore. It will now automatically deploy. (re-operate this after re-deploying)
kubectl get deployment
.kubectl get pod -o yaml
>> spec.containers
.services/my_backend/image
kubectl get pods
kubectl logs [pod_name]
If this works well, [Kubernetes Engine] --> [service] --> my-backend-02's Endpoints
β€ With this endpoint, you can now access to playground.
Mine: 34.64.102.24:3000/graphql
1. Go to cloud SQL and copy your {private IP Address}.
2. Change the [vscode-->app.module.ts]'s host to private IP Address. Also, after changing the host, update the tag in `docker-compose.prod.yaml file`.
3. Then do build and push again to upload to "container registry".
Open cloud shell and connect to Kubernetes cluster.
kubectl get pod -o yaml
to check the image name first.kubectl set image deployment/[μ€νμ€μΈ deployment λͺ
] [λ°°ν¬λ image name]=[cotainer registryμ λ±λ‘λ image]
kubectl logs [pod name]
kubectl rollout restart deployment [deployment_name]
.kubectl logs [pod name]
and check the logs.Ingress : Cluster's Entrypoint
β€ Ingress balances traffic to the right route to service.
route :: [Kubernetes Engine] --> [Services and Ingress] --> check my-backend-02 (service) and click {create ingress}
External HTTP/S load balancer
Host and path rules >> Backends 1 : `my-backend-02`
Frontend configuration >> Protocol : HTTPS,
--> Create a new certificate >> name anything // "create google-managed certificate" // domain : jbeeshop.shop
Then go to Network Service > Cloud DNS > Change A redocr to Ingress IP Address
JSON file connection
touch gcp-file-storage.json
<< create JSON file in pod
vi gcp-file-storage.json
<< fill up the JSON file
β€ i
<< insert mode
β€ insert the copied text from gcp-file-storage.json
from vscode.
β€ esc
and :wq
to save and quit.
kubectl create secret
<< make this json file into secret mode.
kubectl create secret generic my-backend-secrets --from-file=gcp-file-storage.json=./gcp-file-storage.json
<< create
kubectl get secrets
<< view
Afterall, edit vscode > file.service.ts > keyFilename
to 'my-secret/gcp-file-storage.json'.
β€ Do build and push again in vscode.
Cloud shell : kubectl set image deployment/my-backend-02 my-backend02-sha256-1=asia.gcr.io/wise-invention-347011/my-backend02:11
Then go back to GCP and go to Kubernetes Engine > Workload > my-backend-02
Click YAML and edit yaml like this:
Then go to postman and request image upload API to check wether the image successfully saves to the storage.