项目作者: mathieu-benoit

项目描述 :
Kubernetes Network Policies samples
高级语言:
项目地址: git://github.com/mathieu-benoit/k8s-netpol.git
创建时间: 2019-09-28T21:32:12Z
项目社区:https://github.com/mathieu-benoit/k8s-netpol

开源协议:

下载


Kubernetes resources leveraged and illustrated by this blog article I wrote: Kubernetes Network Policies, how to secure the communications between your pods

Deployments and NetworkPolicies Overview

To summarize, here are the bash commands you need to run:

  1. # Get you AKS cluster with Calico enabled
  2. az aks create... \
  3. --network-policy calico
  4. # Since we would like to allow DNS resolution from WEB and API to respectively call API and DB we need to create a Label on the kube-system Namespace
  5. kubectl label ns kube-system name=kube-system
  6. # Create a Namespace to deploy K8S resources into it
  7. ns=yournamespace
  8. kubectl create ns $ns
  9. kubectl config set-context \
  10. --current \
  11. --namespace $ns
  12. # Deploy WEB, API and DB Pods/Services
  13. kubectl apply \
  14. -f db-api-web-deployments.yaml
  15. # Apply the first NetworkPolicy: deny all Ingress/Egress
  16. kubectl apply \
  17. -f deny-all-netpol.yaml
  18. # Apply the NetworkPolicy definition related to DB
  19. kubectl apply \
  20. -f db-netpol.yaml
  21. # Apply the NetworkPolicy definition related to API
  22. kubectl apply \
  23. -f api-netpol.yaml
  24. # Apply the NetworkPolicy definition related to WEB
  25. kubectl apply \
  26. -f web-netpol.yaml