Prepare environment
- Download sources.
- Configure gcloud unitily to work with current project.
gcloud auth login
gcloud config list project
gcloud config list
- Download credentials.json due to official documentation.
- Configure path to
credentials.json
file inmain.tf
- Install GKE.
cd terraform
terrafrom plan
terrafrom apply
Build docker image 6. Change directory to "application/java"
cd application
- Configure docker to use Google container registry. (gcloud should be already configured to your project)
gcloud alpha auth configure-docker
- Build docker image and according to PROJECT_ID You can use following command to get PROJECT_ID
export PROJECT_ID="$(gcloud config get-value project -q)"
echo $PROJECT_ID
docker build -t eu.gcr.io/$PROJECT_ID/java_app:v1 .
Check application
docker run --rm eu.gcr.io/$PROJECT_ID/java_app:v1
- Push image to google cloud registry
docker push eu.gcr.io/$PROJECT_ID/java_app:v1
- Prepare kubectl to work with deployed k8s.
gcloud container clusters get-credentials k8skiwi-cluster --zone europe-west2-a --project $PROJECT_ID
- Set correct
image
name inkubernetes/deployment.yml
(from previous push) - Deploy application, service and ingress to Kubernetes
cd kubernetes
kubectl apply -f deployment.yml
kubectl apply -f service.yml
kubectl apply -f ingress.yml
- Get ingress external endpoint and check connection
kubectl get ingress