-
Notifications
You must be signed in to change notification settings - Fork 884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugging warnings in pss workflow #2866
Changes from 78 commits
7ab6e55
0f00b27
a3fd0ed
b239d2a
13f5972
66f6493
e8829c3
b22ced2
ab29ecf
39bd95b
5f0741a
cbed790
e00b5da
519fef4
928ffb9
b504f36
363113c
63821aa
c3a7798
262c78c
9a21438
86c9577
3db6583
74eb10e
9ace6ac
005500c
77f400a
6f9d201
241f948
a564ded
3de18f4
b7dd0bf
c5ccd37
94a351f
17a35c4
7f521f2
04fb9a7
09e0c84
7492290
bd13b6d
5cc7aa6
43f6b3b
a495be7
f496072
523febc
cdbea53
cb04ee9
8448450
233dc59
4bbbdeb
9d8d641
f31179a
c4693b1
d9b6250
5a2f711
c59a8f8
8754c92
5e8fd14
10a23ae
bce60a3
9b95dc6
a713a4c
bb20a6b
c2af245
d6ebc3f
86c372c
b88fe8f
523f9a0
2bd7e07
d0f3cc6
5743a1f
65ec9f7
b00fe48
0cd0454
0cd2870
f3cace5
2cb79fb
5ed56cf
e40311f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: Apply PSS labels to namespaces | ||
on: | ||
pull_request: | ||
paths: | ||
- tests/gh-actions/install_KinD_create_KinD_cluster_install_kustomize.sh | ||
|
@@ -11,7 +11,7 @@ | |
- common/cert-manager/** | ||
- common/oauth2-proxy/** | ||
- common/istio*/** | ||
- tests/gh-actions/install_istio_with_ext_auth.sh | ||
- tests/gh-actions/install_istio-cni.sh | ||
- tests/gh-actions/install_multitenancy.sh | ||
|
||
jobs: | ||
|
@@ -27,12 +27,25 @@ | |
- name: Install kubectl | ||
run: ./tests/gh-actions/install_kubectl.sh | ||
|
||
- name: Install all deployments from static namespaces | ||
- name: Install all istio-cni resources and kubeflow namespace | ||
run: | | ||
kustomize build common/kubeflow-namespace/base | kubectl apply -f - | ||
./tests/gh-actions/install_cert_manager.sh | ||
./tests/gh-actions/install_istio_with_ext_auth.sh | ||
kustomize build common/istio-1-22/kubeflow-istio-resources/base | kubectl apply -f - | ||
./tests/gh-actions/install_istio-cni.sh | ||
kustomize build common/istio-cni-1-22/kubeflow-istio-resources/base | kubectl apply -f - | ||
|
||
- name: Configure istio init container with seccompProfile attribute | ||
run: | | ||
kubectl get cm istio-sidecar-injector -n istio-system -o yaml > temporary_patch.yaml | ||
sed -i '0,/runAsNonRoot: true/{s//&\n seccompProfile:\n type: RuntimeDefault/}' temporary_patch.yaml | ||
sed -i '/runAsNonRoot: true/{N; /runAsUser: {{ .ProxyUID | default "1337" }}/a\ | ||
seccompProfile:\n type: RuntimeDefault | ||
}' temporary_patch.yaml | ||
kubectl apply -f temporary_patch.yaml | ||
rm temporary_patch.yaml | ||
|
||
- name: Install all other deployments of static namespaces | ||
run: | | ||
./tests/gh-actions/install_multi_tenancy.sh | ||
kustomize build ./common/oauth2-proxy/overlays/m2m-self-signed | kubectl apply -f - | ||
echo "Waiting for all oauth2-proxy pods to become ready..." | ||
|
@@ -41,35 +54,27 @@ | |
echo "Waiting for pods in auth namespace to become ready..." | ||
kubectl wait --for=condition=Ready pods --all --timeout=180s -n auth | ||
|
||
# - name: Configure profile-controller's manager configmap with PSS restricted label | ||
# run: | | ||
# CONFIGMAP=$(kubectl get cm -n kubeflow | awk '{print $1}' | grep -e "namespace-labels-data") | ||
# kubectl get cm $CONFIGMAP -n kubeflow -o yaml > temporary.yaml | ||
# sed -i '/app.kubernetes.io\/part-of: "kubeflow-profile"/{s/.*/&\n pod-security.kubernetes.io\/enforce: "restricted"/}' temporary.yaml | ||
# kubectl apply -f temporary.yaml | ||
# rm temporary.yaml | ||
|
||
- name: Install KF Pipelines | ||
run: ./tests/gh-actions/install_pipelines.sh | ||
|
||
- name: Apply Pod Security Standards baseline levels for static namespaces | ||
run: ./tests/gh-actions/enable_baseline_PSS.sh | ||
|
||
- name: Apply Pod Security Standards baseline levels for dynamic namespaces | ||
run: | | ||
cat << EOF > ./kustomization.yaml | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- apps/profiles/upstream/overlays/kubeflow | ||
components: | ||
- contrib/security/PSS/dynamic/baseline | ||
EOF | ||
kubectl apply -k . | ||
rm ./kustomization.yaml | ||
kubectl -n kubeflow wait --for=condition=Ready pods -l kustomize.component=profiles --timeout 180s | ||
|
||
- name: Unapply applied baseline values | ||
run: | | ||
NAMESPACES=("istio-system" "auth" "cert-manager" "oauth2-proxy" "kubeflow") | ||
for NAMESPACE in "${NAMESPACES[@]}"; do | ||
if kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then | ||
kubectl label namespace $NAMESPACE pod-security.kubernetes.io/enforce- | ||
fi | ||
done | ||
sleep 10 | ||
# - name: Create dynamic user namespace and check for PSS labels present | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the debugging parts, such that we can merge soon. Let's just finish these three comments and merge. This PR is getting too big and we should continue in new ones. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debugging parts along with patch for dynamic namespaces have also been removed in the commit e40311f. I believe that can be done in a new PR to keep things simple. |
||
# run: | | ||
# kustomize build common/user-namespace/base | kubectl apply -f - | ||
# LABELS=$(kubectl get namespace kubeflow-user-example-com --show-labels | awk 'NR==2 {print $NF}') | ||
# if [[ "$LABELS" == *pod-security.kubernetes.io/enforce=restricted* ]]; then | ||
# echo "PSS restricted label is present in dynamic namespace." | ||
# else | ||
# echo "PSS restricted label is absent in dynamic namespace." | ||
# exit 1 | ||
# fi | ||
|
||
- name: Apply patches to clear warnings | ||
run: | | ||
|
@@ -87,6 +92,19 @@ | |
kubectl patch "$KIND" "$NAME" -n "$NAMESPACE" --patch-file "$file" | ||
fi | ||
done | ||
sleep 600 | ||
|
||
- name: Apply Pod Security Standards baseline levels for static namespaces | ||
run: ./tests/gh-actions/enable_baseline_PSS.sh | ||
|
||
- name: Unapply applied baseline labels | ||
run: | | ||
NAMESPACES=("istio-system" "auth" "cert-manager" "oauth2-proxy" "kubeflow") | ||
for NAMESPACE in "${NAMESPACES[@]}"; do | ||
if kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then | ||
kubectl label namespace $NAMESPACE pod-security.kubernetes.io/enforce- | ||
fi | ||
done | ||
|
||
- name: Applying Pod Security Standards restricted levels for static namespaces | ||
run: ./tests/gh-actions/enable_restricted_PSS.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: metacontroller | ||
namespace: kubeflow | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: metacontroller | ||
securityContext: | ||
seccompProfile: | ||
type: RuntimeDefault |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,14 @@ spec: | |
seccompProfile: | ||
type: RuntimeDefault | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
runAsGroup: 0 | ||
capabilities: | ||
drop: | ||
- ALL | ||
initContainers: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove all the istio initcontainer patches from all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. initContainers have been removed in the commit e40311f |
||
- image: docker.io/istio/proxyv2:1.22.1 | ||
name: istio-validation | ||
securityContext: | ||
seccompProfile: | ||
type: RuntimeDefault |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ metadata: | |
name: oauth2-proxy | ||
namespace: oauth2-proxy | ||
spec: | ||
replicas: 2 | ||
template: | ||
spec: | ||
containers: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: workflow-controller | ||
namespace: kubeflow | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: workflow-controller | ||
securityContext: | ||
seccompProfile: | ||
type: RuntimeDefault | ||
runAsNonRoot: true | ||
initContainers: | ||
- image: docker.io/istio/proxyv2:1.22.1 | ||
name: istio-validation | ||
securityContext: | ||
seccompProfile: | ||
type: RuntimeDefault |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good :-) according to the workflow results it seems to work, but please verify it manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I did run it manually and opened up the configmap to observe the changes in place as we want. Also, I have removed the comments which I can later add as commits for dynamic namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ml-pipeline pod in my local system does seem to fail with CrashLoopBackOff as I open it up. Maybe I need to increase my fs.inotify.max_user_{instances, watches} .