-
Clone the repository
git clone https://github.com/GoogleCloudPlatform/gke-network-policy-demo.git cd gke-network-policy-demo
-
Set region and zone
gcloud config set compute/region us-central1 gcloud config set compute/zone us-central1-a
-
Enable API & generate terrraform
make setup-project
cat terraform/terraform.tfvars
-
Apply terraform
make tf-apply
-
Verify networkPolicyEnabled and networkPolicyProvider
gcloud container clusters describe gke-demo-cluster | grep -A2 networkPolicy
-
SSH to bastion host
gcloud compute ssh gke-demo-bastion
-
Install
sudo apt-get install google-cloud-sdk-gke-gcloud-auth-plugin
echo "export USE_GKE_GCLOUD_AUTH_PLUGIN=True" >> ~/.bashrc
-
Run
source ~/.bashrc
gcloud container clusters get-credentials gke-demo-cluster --zone us-central1-a
-
Run
kubectl apply -f ./manifests/hello-app/
kubectl get pods
-
Cek logs
kubectl logs --tail 10 -f $(kubectl get pods -oname -l app=hello)
kubectl logs --tail 10 -f $(kubectl get pods -oname -l app=not-hello)
-
Terapkan policy
kubectl apply -f ./manifests/network-policy.yaml
-
Cek logs
kubectl logs --tail 10 -f $(kubectl get pods -oname -l app=not-hello)
-
Delete network policy
kubectl delete -f ./manifests/network-policy.yaml
-
Buat namespace
kubectl create -f ./manifests/network-policy-namespaced.yaml
-
Cek log
kubectl logs --tail 10 -f $(kubectl get pods -oname -l app=hello)
-
Deploy
kubectl -n hello-apps apply -f ./manifests/hello-app/hello-client.yaml
-
Cek logs
kubectl logs --tail 10 -f -n hello-apps $(kubectl get pods -oname -l app=hello -n hello-apps)
-
Exit from bastion host
exit
-
Destroy environment
make teardown