Skip to content
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

Psa downstream #349

Merged
merged 4 commits into from Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions manifests/0000_50_olm_00-namespace.yaml
Expand Up @@ -2,23 +2,25 @@ apiVersion: v1
kind: Namespace
metadata:
name: openshift-operator-lifecycle-manager
labels:
openshift.io/scc: "anyuid"
openshift.io/cluster-monitoring: "true"
annotations:
openshift.io/node-selector: ""
workload.openshift.io/allowed: "management"
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
labels:
openshift.io/scc: "anyuid"
openshift.io/cluster-monitoring: "true"
---
apiVersion: v1
kind: Namespace
metadata:
name: openshift-operators
labels:
pod-security.kubernetes.io/enforce: baseline
pod-security.kubernetes.io/enforce-version: "v1.24"
openshift.io/scc: "anyuid"
annotations:
openshift.io/node-selector: ""
workload.openshift.io/allowed: "management"
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
labels:
openshift.io/scc: "anyuid"
Expand Up @@ -23,7 +23,6 @@ spec:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
serviceAccountName: olm-operator-serviceaccount
Expand Down
1 change: 0 additions & 1 deletion manifests/0000_50_olm_06-psm-operator.deployment.yaml
Expand Up @@ -23,7 +23,6 @@ spec:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
serviceAccountName: olm-operator-serviceaccount
Expand Down
Expand Up @@ -21,6 +21,10 @@ spec:
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
serviceAccountName: olm-operator-serviceaccount
volumes:
- name: srv-cert
Expand All @@ -31,6 +35,10 @@ spec:
secretName: pprof-cert
containers:
- name: olm-operator
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: srv-cert
mountPath: "/srv-cert"
Expand Down Expand Up @@ -82,10 +90,6 @@ spec:
requests:
cpu: 10m
memory: 160Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
nodeSelector:
kubernetes.io/os: linux
tolerations:
Expand All @@ -101,8 +105,3 @@ spec:
operator: Exists
tolerationSeconds: 120
priorityClassName: system-cluster-critical
securityContext:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
17 changes: 8 additions & 9 deletions manifests/0000_50_olm_07-olm-operator.deployment.yaml
Expand Up @@ -21,6 +21,10 @@ spec:
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
serviceAccountName: olm-operator-serviceaccount
volumes:
- name: srv-cert
Expand All @@ -31,6 +35,10 @@ spec:
secretName: pprof-cert
containers:
- name: olm-operator
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: srv-cert
mountPath: "/srv-cert"
Expand Down Expand Up @@ -82,10 +90,6 @@ spec:
requests:
cpu: 10m
memory: 160Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
nodeSelector:
kubernetes.io/os: linux
node-role.kubernetes.io/master: ""
Expand All @@ -102,8 +106,3 @@ spec:
operator: Exists
tolerationSeconds: 120
priorityClassName: system-cluster-critical
securityContext:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
Expand Up @@ -21,6 +21,10 @@ spec:
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
serviceAccountName: olm-operator-serviceaccount
volumes:
- name: srv-cert
Expand All @@ -31,6 +35,10 @@ spec:
secretName: pprof-cert
containers:
- name: catalog-operator
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: srv-cert
mountPath: "/srv-cert"
Expand All @@ -55,6 +63,7 @@ spec:
- /srv-cert/tls.key
- --client-ca
- /profile-collector-cert/tls.crt
- --set-workload-user-id=false
image: quay.io/operator-framework/olm@sha256:de396b540b82219812061d0d753440d5655250c621c753ed1dc67d6154741607
imagePullPolicy: IfNotPresent
ports:
Expand All @@ -78,10 +87,6 @@ spec:
env:
- name: RELEASE_VERSION
value: "0.0.1-snapshot"
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
nodeSelector:
kubernetes.io/os: linux
tolerations:
Expand All @@ -97,8 +102,3 @@ spec:
operator: Exists
tolerationSeconds: 120
priorityClassName: system-cluster-critical
securityContext:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
18 changes: 9 additions & 9 deletions manifests/0000_50_olm_08-catalog-operator.deployment.yaml
Expand Up @@ -21,6 +21,10 @@ spec:
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
serviceAccountName: olm-operator-serviceaccount
volumes:
- name: srv-cert
Expand All @@ -31,6 +35,10 @@ spec:
secretName: pprof-cert
containers:
- name: catalog-operator
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: srv-cert
mountPath: "/srv-cert"
Expand All @@ -55,6 +63,7 @@ spec:
- /srv-cert/tls.key
- --client-ca
- /profile-collector-cert/tls.crt
- --set-workload-user-id=false
image: quay.io/operator-framework/olm@sha256:de396b540b82219812061d0d753440d5655250c621c753ed1dc67d6154741607
imagePullPolicy: IfNotPresent
ports:
Expand All @@ -78,10 +87,6 @@ spec:
env:
- name: RELEASE_VERSION
value: "0.0.1-snapshot"
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
nodeSelector:
kubernetes.io/os: linux
node-role.kubernetes.io/master: ""
Expand All @@ -98,8 +103,3 @@ spec:
operator: Exists
tolerationSeconds: 120
priorityClassName: system-cluster-critical
securityContext:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
17 changes: 8 additions & 9 deletions pkg/manifests/csv.yaml
Expand Up @@ -88,6 +88,10 @@ spec:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
creationTimestamp: null
spec:
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
serviceAccountName: olm-operator-serviceaccount
nodeSelector:
kubernetes.io/os: linux
Expand All @@ -106,6 +110,10 @@ spec:
tolerationSeconds: 120
containers:
- name: packageserver
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
command:
- /bin/package-server
- -v=4
Expand Down Expand Up @@ -136,10 +144,6 @@ spec:
volumeMounts:
- name: tmpfs
mountPath: /tmp
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumes:
- name: tmpfs
emptyDir: {}
Expand All @@ -154,11 +158,6 @@ spec:
values:
- packageserver
topologyKey: "kubernetes.io/hostname"
securityContext:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
maturity: alpha
version: 0.19.0
apiservicedefinitions:
Expand Down
1 change: 0 additions & 1 deletion scripts/catalog-deployment.patch.yaml
Expand Up @@ -19,6 +19,5 @@
path: spec.template.spec.securityContext
value:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
3 changes: 2 additions & 1 deletion scripts/generate_crds_manifests.sh
Expand Up @@ -133,7 +133,6 @@ spec:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
serviceAccountName: olm-operator-serviceaccount
Expand Down Expand Up @@ -367,3 +366,5 @@ add_ibm_managed_cloud_annotations "${ROOT_DIR}/manifests"

find "${ROOT_DIR}/manifests" -type f -exec $SED -i "/^#/d" {} \;
find "${ROOT_DIR}/manifests" -type f -exec $SED -i "1{/---/d}" {} \;

${YQ} delete --inplace -d'0' manifests/0000_50_olm_00-namespace.yaml 'metadata.labels."pod-security.kubernetes.io/enforce*"'
1 change: 0 additions & 1 deletion scripts/olm-deployment.patch.yaml
Expand Up @@ -19,6 +19,5 @@
path: spec.template.spec.securityContext
value:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
1 change: 0 additions & 1 deletion scripts/packageserver-deployment.patch.yaml
Expand Up @@ -43,6 +43,5 @@
path: spec.install.spec.deployments[0].spec.template.spec.securityContext
value:
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
1 change: 1 addition & 0 deletions staging/operator-lifecycle-manager/Dockerfile
Expand Up @@ -33,6 +33,7 @@ COPY --from=builder /build/bin/olm /bin/olm
COPY --from=builder /build/bin/catalog /bin/catalog
COPY --from=builder /build/bin/package-server /bin/package-server
COPY --from=builder /build/bin/cpb /bin/cpb
USER 1001
EXPOSE 8080
EXPOSE 5443
CMD ["/bin/olm"]
1 change: 1 addition & 0 deletions staging/operator-lifecycle-manager/Dockerfile.goreleaser
Expand Up @@ -10,4 +10,5 @@ COPY package-server /bin/package-server
COPY cpb /bin/cpb
EXPOSE 8080
EXPOSE 5443
USER 1001
ENTRYPOINT ["/bin/olm"]
6 changes: 6 additions & 0 deletions staging/operator-lifecycle-manager/cmd/catalog/main.go
Expand Up @@ -30,6 +30,7 @@ const (
defaultOPMImage = "quay.io/operator-framework/upstream-opm-builder:latest"
defaultUtilImage = "quay.io/operator-framework/olm:latest"
defaultOperatorName = ""
defaultWorkLoadUserID = int64(1001)
)

// config flags defined globally so that they appear on the test binary as well
Expand Down Expand Up @@ -83,6 +84,10 @@ func (o *options) run(ctx context.Context, logger *logrus.Logger) error {
return fmt.Errorf("error configuring client: %s", err.Error())
}

workloadUserID := int64(-1)
if o.setWorkloadUserID {
workloadUserID = defaultWorkLoadUserID
}
// TODO(tflannag): Use options pattern for catalog operator
// Create a new instance of the operator.
op, err := catalog.NewOperator(
Expand All @@ -98,6 +103,7 @@ func (o *options) run(ctx context.Context, logger *logrus.Logger) error {
k8sscheme.Scheme,
o.installPlanTimeout,
o.bundleUnpackTimeout,
workloadUserID,
)
if err != nil {
return fmt.Errorf("error configuring catalog operator: %s", err.Error())
Expand Down
2 changes: 2 additions & 0 deletions staging/operator-lifecycle-manager/cmd/catalog/start.go
Expand Up @@ -25,6 +25,7 @@ type options struct {
tlsKeyPath string
tlsCertPath string
clientCAPath string
setWorkloadUserID bool

installPlanTimeout time.Duration
bundleUnpackTimeout time.Duration
Expand Down Expand Up @@ -66,6 +67,7 @@ func newRootCmd() *cobra.Command {
cmd.Flags().StringVar(&o.opmImage, "opmImage", defaultOPMImage, "the image to use for unpacking bundle content with opm")
cmd.Flags().StringVar(&o.utilImage, "util-image", defaultUtilImage, "an image containing custom olm utilities")
cmd.Flags().StringVar(&o.writeStatusName, "writeStatusName", defaultOperatorName, "ClusterOperator name in which to write status, set to \"\" to disable.")
cmd.Flags().BoolVar(&o.setWorkloadUserID, "set-workload-user-id", false, "set user ID for all workloads (registry pods/bundle unpack jobs to default 1001")

cmd.Flags().BoolVar(&o.debug, "debug", false, "use debug log level")
cmd.Flags().BoolVar(&o.version, "version", false, "displays the olm version")
Expand Down
Expand Up @@ -2,9 +2,19 @@ apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.namespace }}
labels:
{{- if .Values.namespace_psa }}
pod-security.kubernetes.io/enforce: {{ .Values.namespace_psa.enforceLevel }}
pod-security.kubernetes.io/enforce-version: {{ .Values.namespace_psa.enforceVersion }}
{{- end }}

---
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.operator_namespace }}
labels:
{{- if .Values.operator_namespace_psa }}
pod-security.kubernetes.io/enforce: {{ .Values.operator_namespace_psa.enforceLevel }}
pod-security.kubernetes.io/enforce-version: {{ .Values.operator_namespace_psa.enforceVersion }}
{{- end }}