Skip to content

Commit

Permalink
Merge branch 'main' into kirby-zone-topology
Browse files Browse the repository at this point in the history
  • Loading branch information
kabicin authored Jul 27, 2023
2 parents 9a37aff + a516104 commit cd988f7
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 61 deletions.
104 changes: 101 additions & 3 deletions .one-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ setup:
script: |
#!/usr/bin/env bash
echo "setup"
echo $STAGE
# Download Go
GO_VERSION=$(get_env go-version)
Expand Down Expand Up @@ -78,6 +78,8 @@ test:
script: |
#!/usr/bin/env bash
echo $STAGE
PERIODIC_SCAN=$(get_env periodic-rescan)
PERIODIC_SCAN="$(echo "$PERIODIC_SCAN" | tr '[:upper:]' '[:lower:]')"
Expand Down Expand Up @@ -108,6 +110,8 @@ static-scan:
script: |
#!/usr/bin/env bash
echo $STAGE
PERIODIC_SCAN=$(get_env periodic-rescan)
PERIODIC_SCAN="$(echo "$PERIODIC_SCAN" | tr '[:upper:]' '[:lower:]')"
Expand All @@ -116,6 +120,14 @@ static-scan:
exit 0
fi
SKIP_SCANS=$(get_env SKIP_SCANS)
SKIP_SCANS="$(echo "$SKIP_SCANS" | tr '[:upper:]' '[:lower:]')"
if [[ ! -z "$SKIP_SCANS" && "$SKIP_SCANS" != "false" && "$SKIP_SCANS" != "no" ]]; then
echo "Skipping static-scan. This is a test run only"
exit 0
fi
BRANCH=$(get_env branch)
read -r SONAR_HOST_URL <<< "$(get_env sonarqube | jq -r '.parameters.dashboard_url' | sed 's:/*$::')"
read -r SONAR_USER <<< "$(get_env sonarqube | jq -r '.parameters.user_login')"
Expand All @@ -139,7 +151,52 @@ static-scan:
## Perform static lint
./scripts/pipeline/static-linter-scan.sh --git-token $(get_env git-token) --static-linter-version $(get_env static-linter-version)
compliance-checks:
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.3
dind: true
abort_on_failure: false
image_pull_policy: IfNotPresent
sources:
- repo: https://github.ibm.com/open-toolchain/compliance-commons.git
sha: 38149a3644798c0b5679e6d8cdf999ce7f6e5142
path: cra
- repo: https://github.ibm.com/open-toolchain/compliance-commons.git
sha: 56cb780f891167b93b95d6f477ad7dce79f3df16
path: doi
- repo: https://github.ibm.com/open-toolchain/compliance-commons.git
sha: 7815b2273f9721d6edbdaf9bddb18e44d070b238
path: detect-secrets
- repo: https://github.ibm.com/open-toolchain/compliance-commons.git
sha: 38149a3644798c0b5679e6d8cdf999ce7f6e5142
path: compliance-checks
- repo: https://github.ibm.com/open-toolchain/compliance-commons.git
sha: 3e927695cfdb4f1bb8b25697ae67a10983de9a8c
path: mend

script: |
#!/usr/bin/env bash
echo $STAGE
PERIODIC_SCAN=$(get_env periodic-rescan)
PERIODIC_SCAN="$(echo "$PERIODIC_SCAN" | tr '[:upper:]' '[:lower:]')"
if [[ ! -z "$PERIODIC_SCAN" && "$PERIODIC_SCAN" != "false" && "$PERIODIC_SCAN" != "no" ]]; then
echo "Skipping static-scan. This is a periodic run that is only meant to produce CVE information."
exit 0
fi
SKIP_SCANS=$(get_env SKIP_SCANS)
SKIP_SCANS="$(echo "$SKIP_SCANS" | tr '[:upper:]' '[:lower:]')"
if [[ ! -z "$SKIP_SCANS" && "$SKIP_SCANS" != "false" && "$SKIP_SCANS" != "no" ]]; then
echo "Skipping static-scan. This is a test run only"
exit 0
fi
"${COMMONS_PATH}"/compliance-checks/run.sh
containerize:
dind: true
abort_on_failure: true
Expand Down Expand Up @@ -349,7 +406,8 @@ sign-artifact:
image: icr.io/continuous-delivery/pipeline/image-signing:1.0.0@sha256:e9d8e354668ba3d40be2aaee08298d2aa7f0e1c8a1829cca4094ec93830e3e6a
script: |
#!/usr/bin/env bash
echo "sign-artifact"
echo $STAGE
PERIODIC_SCAN=$(get_env periodic-rescan)
PERIODIC_SCAN="$(echo "$PERIODIC_SCAN" | tr '[:upper:]' '[:lower:]')"
Expand All @@ -359,12 +417,21 @@ sign-artifact:
exit 0
fi
SKIP_SCANS=$(get_env SKIP_SCANS)
SKIP_SCANS="$(echo "$SKIP_SCANS" | tr '[:upper:]' '[:lower:]')"
if [[ ! -z "$SKIP_SCANS" && "$SKIP_SCANS" != "false" && "$SKIP_SCANS" != "no" ]]; then
echo "Skipping static-scan. This is a test run only"
exit 0
fi
deploy:
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.12

script: |
#!/usr/bin/env bash
echo $STAGE
PERIODIC_SCAN=$(get_env periodic-rescan)
PERIODIC_SCAN="$(echo "$PERIODIC_SCAN" | tr '[:upper:]' '[:lower:]')"
Expand All @@ -386,7 +453,9 @@ dynamic-scan:
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.12
script: |
#!/usr/bin/env bash
echo "dynamic-scan"
echo $STAGE
PERIODIC_SCAN=$(get_env periodic-rescan)
PERIODIC_SCAN="$(echo "$PERIODIC_SCAN" | tr '[:upper:]' '[:lower:]')"
Expand All @@ -395,6 +464,14 @@ dynamic-scan:
exit 0
fi
SKIP_SCANS=$(get_env SKIP_SCANS)
SKIP_SCANS="$(echo "$SKIP_SCANS" | tr '[:upper:]' '[:lower:]')"
if [[ ! -z "$SKIP_SCANS" && "$SKIP_SCANS" != "false" && "$SKIP_SCANS" != "no" ]]; then
echo "Skipping static-scan. This is a test run only"
exit 0
fi
#export APP_URL=$(cat ../app-url)
# feature preview this until evidence locker v2 usage is full feature ready
# can be triggered, and owasp will run for preview purposes
Expand Down Expand Up @@ -449,6 +526,16 @@ scan-artifact:
script: |
#!/usr/bin/env bash
echo $STAGE
SKIP_SCANS=$(get_env SKIP_SCANS)
SKIP_SCANS="$(echo "$SKIP_SCANS" | tr '[:upper:]' '[:lower:]')"
if [[ ! -z "$SKIP_SCANS" && "$SKIP_SCANS" != "false" && "$SKIP_SCANS" != "no" ]]; then
echo "Skipping static-scan. This is a test run only"
exit 0
fi
# ========== Security Scanner ==========
./scripts/pipeline/ci_to_secure_pipeline_scan.sh
Expand All @@ -457,6 +544,9 @@ release:
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.12
script: |
#!/usr/bin/env bash
echo $STAGE
PERIODIC_SCAN=$(get_env periodic-rescan)
PERIODIC_SCAN="$(echo "$PERIODIC_SCAN" | tr '[:upper:]' '[:lower:]')"
Expand All @@ -465,6 +555,14 @@ release:
exit 0
fi
SKIP_SCANS=$(get_env SKIP_SCANS)
SKIP_SCANS="$(echo "$SKIP_SCANS" | tr '[:upper:]' '[:lower:]')"
if [[ ! -z "$SKIP_SCANS" && "$SKIP_SCANS" != "false" && "$SKIP_SCANS" != "no" ]]; then
echo "Skipping static-scan. This is a test run only"
exit 0
fi
RELEASE_FLAG=$(get_env release "false")
if [[ $RELEASE_FLAG != "true" ]]; then
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ bundle: manifests setup kustomize ## Generate bundle manifests and metadata, the
$(KUSTOMIZE) build config/kubectl/rbac-watch-all -o internal/deploy/kubectl/runtime-component-rbac-watch-all.yaml
$(KUSTOMIZE) build config/kubectl/rbac-watch-another -o internal/deploy/kubectl/runtime-component-rbac-watch-another.yaml

$(KUSTOMIZE) build config/kustomize/watch-all -o internal/deploy/kustomize/daily/overlays/watch-all-namespaces/cluster-roles.yaml
$(KUSTOMIZE) build config/kustomize/watch-another -o internal/deploy/kustomize/daily/overlays/watch-another-namespace/rco-watched-ns/watched-roles.yaml

operator-sdk bundle validate ./bundle

.PHONY: fmt
Expand Down
93 changes: 93 additions & 0 deletions config/kustomize/watch-all/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../rbac

# Labels to add to all resources and selectors.
commonLabels:
app.kubernetes.io/instance: runtime-component-operator
app.kubernetes.io/name: runtime-component-operator

patches:
- path: patches/delete-service-account.yaml
target:
kind: ServiceAccount

patchesJson6902:
- target:
namespace: runtime-component-operator
name: .*
patch: |-
- op: remove
path: /metadata/namespace
- target:
kind: Role
name: .*
patch: |-
- op: replace
path: /kind
value: ClusterRole
- target:
kind: RoleBinding
name: .*
patch: |-
- op: replace
path: /kind
value: ClusterRoleBinding
- target:
kind: ClusterRoleBinding
name: .*
patch: |-
- op: replace
path: /subjects/0/name
value: rco-controller-manager
- op: replace
path: /subjects/0/namespace
value: RUNTIME_COMPONENT_OPERATOR_NAMESPACE
- op: replace
path: /roleRef/kind
value: ClusterRole
- target:
kind: ClusterRoleBinding
name: leader-election-rolebinding
patch: |-
- op: replace
path: /roleRef/name
value: rco-leader-election-cluster-role
- op: replace
path: /metadata/name
value: rco-leader-election-cluster-rolebinding
- target:
kind: ClusterRoleBinding
name: manager-rolebinding
patch: |-
- op: replace
path: /metadata/name
value: rco-manager-cluster-rolebinding
- op: replace
path: /roleRef/name
value: rco-manager-cluster-role
- target:
kind: ClusterRole
name: manager-role
patch: |-
- op: replace
path: /metadata/name
value: rco-manager-cluster-role
- op: add
path: /rules/-
value: {"apiGroups":[""],"resources":["namespaces"],"verbs":["get","list","watch"]}
- target:
kind: ClusterRoleBinding
name: .*
patch: |-
- op: replace
path: /subjects/0/namespace
value: runtime-component
- target:
kind: ClusterRole
name: leader-election-role
patch: |-
- op: replace
path: /metadata/name
value: rco-leader-election-cluster-role
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$patch: delete
apiVersion: v1
kind: ServiceAccount
metadata:
name: wlo-controller-manager
62 changes: 62 additions & 0 deletions config/kustomize/watch-another/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../rbac

namespace: rco-watched-ns

# Labels to add to all resources and selectors.
commonLabels:
app.kubernetes.io/instance: runtime-component-operator
app.kubernetes.io/name: runtime-component-operator

patches:
- path: patches/delete-service-account.yaml
target:
kind: ServiceAccount

patchesJson6902:
- target:
kind: RoleBinding
name: manager-rolebinding
patch: |-
- op: replace
path: /metadata/name
value: rco-watched-rolebinding
- op: replace
path: /roleRef/name
value: rco-watched-role
- target:
kind: RoleBinding
name: leader-election-rolebinding
patch: |-
- op: replace
path: /metadata/name
value: rco-leader-election-watched-rolebinding
- op: replace
path: /roleRef/name
value: rco-leader-election-watched-role
- target:
kind: RoleBinding
name: .*
patch: |-
- op: replace
path: /subjects/0/namespace
value: rco-ns
- op: replace
path: /subjects/0/name
value: rco-controller-manager
- target:
kind: Role
name: leader-election-role
patch: |-
- op: replace
path: /metadata/name
value: rco-leader-election-watched-role
- target:
kind: Role
name: manager-role
patch: |-
- op: replace
path: /metadata/name
value: rco-watched-role
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$patch: delete
apiVersion: v1
kind: ServiceAccount
metadata:
name: wlo-controller-manager
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spec:
fieldPath: metadata.namespace
- name: RELATED_IMAGE_LIBERTY_SAMPLE_APP
value: icr.io/appcafe/open-liberty/samples/getting-started@sha256:d3c67c4a15c97b0fb82f9ef4a2ccf474232b878787e9eea39af75a3ac78469e3
image: icr.io/appcafe/runtime-component-operator:daily
image: icr.io/appcafe/runtime-component-operator:1.2.1
livenessProbe:
failureThreshold: 3
httpGet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ rules:
resources:
- namespaces
verbs:
- list
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -255,4 +255,3 @@ subjects:
- kind: ServiceAccount
name: rco-controller-manager
namespace: runtime-component
---
Loading

0 comments on commit cd988f7

Please sign in to comment.