Closed cboin1996 closed 2 years ago
Outstanding work:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
labels:
argocd.statcan.gc.ca/instance: network-policies
name: allow-profile-controller-to-internet
namespace: daaas-system
spec:
egress:
- ports:
- port: 5432
protocol: TCP
to:
- ipBlock:
cidr: 0.0.0.0/0
podSelector:
matchLabels:
app.kubernetes.io/name: profiles-controller
policyTypes:
- Egress
The issue appears to be twofold:
5432
is required as @cboin1996 suggested above, andconfigure-gitea
init container is starting before the istio-proxy
container starts up. Because of (2) the init containers don't have networking setup, so the configure-gitea
job cannot connect to the managed postgres instance.I was able to get the configure-gitea
init job to succeed by manually doing the following steps:
securityContext
of the configure-gitea
init container to run as user 1337
.traffic.sidecar.istio.io/excludeOutboundIPRanges: 0.0.0.0/0
and traffic.sidecar.istio.io/excludeOutboundPorts: "5432"
.metadatarestrictions
ConstraintTemplate
. The metadatarestrictions
ConstraintTemplate
has an enforce-protected-b-istio
constraint that prevents the annotations mentioned in (2) from being added to the pod metadata. I was not able to turn off ArgoCD auto-sync, so manually deleting the constraint was the only way to prevent the gitea pod from getting blocked at admission control.Note: steps (1) and (2) are documented by Istio in the following workaround for init containers.
When all 3 steps mentioned above were performed, the configure-gitea
init container was able to complete successfully and the gitea pod started up successfully.
I propose the following next steps - we may wish to discuss as a group as there is a proposed change to a Gatekeeper constraint.
aaw-kubeflow-profiles- controller
as we need to allow this egress to be performed by gitea pods in each namespace that opts into using Gitea. E.g. policy shown belowapiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
labels:
argocd.statcan.gc.ca/instance: network-policies
name: allow-gitea-to-postgres
namespace: christian-boin
spec:
egress:
- ports:
- port: 5432
protocol: TCP
to:
- ipBlock:
cidr: 0.0.0.0/0
podSelector:
matchLabels:
app: gitea
app.kubernetes.io/instance: gitea-protected-b
policyTypes:
- Egress
securityContext
to have the configure-gitea
container run in group 1337
.Both protected-b
and unclassified
Gitea pods schedule and start up successfully with the abovementioned modifications.
Refer to epic here