diff --git a/404.html b/404.html index 342339795..195259289 100644 --- a/404.html +++ b/404.html @@ -10,7 +10,7 @@ - +
diff --git a/assets/js/abc5e328.0f7a396e.js b/assets/js/abc5e328.0f7a396e.js new file mode 100644 index 000000000..99985053a --- /dev/null +++ b/assets/js/abc5e328.0f7a396e.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkredkubes_github_io=self.webpackChunkredkubes_github_io||[]).push([[2115],{2477:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>d,contentTitle:()=>r,default:()=>h,frontMatter:()=>t,metadata:()=>i,toc:()=>c});var l=s(5893),o=s(1151);const t={slug:"create-netpols",title:"Configuring network policies",sidebar_label:"Create Network Policies"},r=void 0,i={id:"get-started/labs/create-netpols",title:"Configuring network policies",description:"In some cases you want to explicitly allow access to your application. This can be done by creating network policies. 2 types of network policies are supported:",source:"@site/docs/get-started/labs/create-netpols.md",sourceDirName:"get-started/labs",slug:"/get-started/labs/create-netpols",permalink:"/docs/get-started/labs/create-netpols",draft:!1,unlisted:!1,editUrl:"https://github.com/linode/linode.github.io/tree/main/docs/get-started/labs/create-netpols.md",tags:[],version:"current",frontMatter:{slug:"create-netpols",title:"Configuring network policies",sidebar_label:"Create Network Policies"},sidebar:"mainSidebar",previous:{title:"Using custom metrics",permalink:"/docs/get-started/labs/custom-metrics"},next:{title:"Use OpenTelemery",permalink:"/docs/get-started/labs/use-otel"}},d={},c=[{value:"Understanding Internal Ingress Network Policies",id:"understanding-internal-ingress-network-policies",level:2},{value:"Understanding Egress Network Policies",id:"understanding-egress-network-policies",level:2},{value:"Setting Up Network Policies for the Example Voting App: An Ingress Example",id:"setting-up-network-policies-for-the-example-voting-app-an-ingress-example",level:2},{value:"Build Images for the Application",id:"build-images-for-the-application",level:3},{value:"Create a Redis Cluster and a PostgreSQL Database",id:"create-a-redis-cluster-and-a-postgresql-database",level:3},{value:"Deploy the Vote App",id:"deploy-the-vote-app",level:3},{value:"Deploy the Worker App",id:"deploy-the-worker-app",level:3},{value:"Deploy the Result App",id:"deploy-the-result-app",level:3},{value:"Register Services for Exposure",id:"register-services-for-exposure",level:3},{value:"Vote",id:"vote",level:4},{value:"Result",id:"result",level:4},{value:"Create the Network Policies for the Example Voting App",id:"create-the-network-policies-for-the-example-voting-app",level:3},{value:"Postgres Database",id:"postgres-database",level:4},{value:"Redis",id:"redis",level:4},{value:"Test the Voting App",id:"test-the-voting-app",level:3},{value:"Setting Up Network Policies for apl-docs.net: An Egress Example",id:"setting-up-network-policies-for-apl-docsnet-an-egress-example",level:2},{value:"Register the Network Policy for apl-docs.net",id:"register-the-network-policy-for-apl-docsnet",level:3},{value:"Deploy Netshoot Pod",id:"deploy-netshoot-pod",level:3},{value:"Test the Egress Network Policy",id:"test-the-egress-network-policy",level:3}];function a(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",ul:"ul",...(0,o.a)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.p,{children:"In some cases you want to explicitly allow access to your application. This can be done by creating network policies. 2 types of network policies are supported:"}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"Policies for ingress traffic inside the cluster."}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"Policies for egress traffic to go outside of the cluster (to access external FQDNs)."}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"understanding-internal-ingress-network-policies",children:"Understanding Internal Ingress Network Policies"}),"\n",(0,l.jsx)(n.p,{children:"The internal ingress network policies allow you to:"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"Deny all traffic to Pods (default mode)"}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"Allow selected Workload Pods running on the cluster to access your Workload's Pods"}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"Allow all traffic to the Pods of a Workload"}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"Deny all"})," and ",(0,l.jsx)(n.code,{children:"Allow all"})," we don't need to explain right?"]}),"\n",(0,l.jsx)(n.admonition,{type:"info",children:(0,l.jsxs)(n.p,{children:["The Ingress Network Policies rely on Pod labels. We require that a single label covers Pods for a given workload. We recommend to use the ",(0,l.jsx)(n.code,{children:"otomi.io/app:The egress rules are namespace wide. You cannot bind an egress policy to one Workload only.
Build the Vote
, Worker
and Result
images from this repo. Use the Build feature to build the images with mode: Docker
. Set the path
to ./vote/Dockerfile
for the Vote image (and ./worker/Dockerfile
for the Worker and ./result/Dockerfile
for Result).
Build the vote
, worker
and result
images from this repo. Use the Build feature to build the images with mode: Docker
. Set the path
to ./vote/Dockerfile
for the Vote image (and ./worker/Dockerfile
for the Worker and ./result/Dockerfile
for Result).
Use the postgresql
and the redis
charts from the Catalog to create a Redis master-replica cluster and a PostgreSQL database. For this lab, Redis authentication needs to be turned off by setting auth.enabled=false
.
Use the k8s-deployment
chart to deploy the vote app. Use the following values:
Name: vote
containerPorts:
- name: http
containerPort: 80
protocol: TCP
env:
- name: REDIS_HOST
value: <redis-cluster-name>-master
containerPorts:
- name: http
containerPort: 80
protocol: TCP
env:
- name: REDIS_HOST
value: <redis-cluster-name>-master
replicaCount: 1
Use the k8s-deployment
chart to deploy the worker app. Use the following values:
Name: worker
containerPorts:
- name: http
containerPort: 80
protocol: TCP
env:
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-app
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-app
key: password
- name: REDIS_HOST
value: <redis-cluster-name>-master
- name: DATABASE_HOST
value: <psql-cluster-name>-rw
containerPorts:
- name: http
containerPort: 80
protocol: TCP
env:
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-app
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-app
key: password
- name: REDIS_HOST
value: <redis-cluster-name>-master
- name: DATABASE_HOST
value: <psql-cluster-name>-rw
replicaCount: 1
The worker pod will show an error “Waiting for db” in the logs. This is an expected error that will be resolved when all the steps in the lab are done.
Use the k8s-deployment
chart to deploy the result app. Use the following values:
Name: result
containerPorts:
- name: http
containerPort: 80
protocol: TCP
env:
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-app
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-app
key: password
- name: DATABASE_HOST
value: <psql-cluster-name>-rw
containerPorts:
- name: http
containerPort: 80
protocol: TCP
env:
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-app
key: username
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: <psql-cluster-name>-app
key: password
- name: DATABASE_HOST
value: <psql-cluster-name>-rw
- name: DATABASE_NAME
value: <psql-cluster-name>
replicaCount: 1
The result pod will show an error “Waiting for db” in the logs. This is an expected error that will be resolved when all the steps in the lab are done.
<result>
service.result
service.External
.Create a new Netpol
and select the ingress
rule type.
Create a new Network policy
and select the ingress
rule type.
Add the selector label name otomi.io/app
.
Select AllowOnly
.
Add the namespace <team-name>
, the selector label name otomi.io/app
and the selector label value <worker>
.
Add the namespace team-<name>
, the selector label name otomi.io/app
and the selector label value worker
.
Add the namespace <team-name>
, the selector label name otomi.io/app
and the selector label value <result>
.
Add the namespace team-<name>
, the selector label name otomi.io/app
and the selector label value result
.
Create a new Netpol
and select the ingress
rule type.
Create a new Network policy
and select the ingress
rule type.
Add the selector label name otomi.io/app
.
AllowOnly
.
Add the namespace <team-name>
, the selector label name otomi.io/app
and the selector label value <worker>
.
Add the namespace team-<name>
, the selector label name otomi.io/app
and the selector label value worker
.
Add the namespace <team-name>
, the selector label name otomi.io/app
and the selector label value <vote>
.
Add the namespace team-<name>
, the selector label name otomi.io/app
and the selector label value vote
.