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

Security context changes #1

Merged
merged 29 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bc31c1a
new file: auto-label.yaml
abimichel Jan 26, 2024
48344cf
update to chart version 1.2.8
abimichel Jan 30, 2024
d5ed1d7
helm dependency build
abimichel Jan 30, 2024
40c95e7
added mysql auto-label
abimichel Jan 31, 2024
14f0ac0
reduced size of database PVC
abimichel Jan 31, 2024
ed11d3f
fixed mysql scc
abimichel Jan 31, 2024
163980a
deleted opensearch poddisruptionbudget.yaml
abimichel Jan 31, 2024
fed5205
initial openmetadata-admin service account
abimichel Jan 31, 2024
f6d21f6
fixed opensearch scc
abimichel Jan 31, 2024
9394aba
custom busybox image
abimichel Jan 31, 2024
c62bb51
modified: .github/workflows/docker-publish.yml
abimichel Jan 31, 2024
2b7c5b9
added branch ref to actions checkout
abimichel Jan 31, 2024
0a21877
modified: .github/workflows/docker-publish.yml
abimichel Jan 31, 2024
dbc997a
move custom opensearch image to GHCR
abimichel Jan 31, 2024
0bfd965
test simplified dockerfile
abimichel Jan 31, 2024
12b4f0b
added opensearch auto-label
abimichel Jan 31, 2024
2fe64b0
increased working dir permissions and added tag
abimichel Jan 31, 2024
907dbdb
changed scc and set to use GHCR
abimichel Jan 31, 2024
d0bb7c5
no longer need the image pull secret
abimichel Jan 31, 2024
ae2c7d5
corrected auto-label policy
abimichel Jan 31, 2024
8231775
added openmetadata and airflow auto-label
abimichel Feb 1, 2024
1fc61ea
deleted openmetadata poddisruptionbudget.yaml
abimichel Feb 1, 2024
835799c
name service account and increase startup probe timeout
abimichel Feb 1, 2024
42e316b
fixed airflow scc
abimichel Feb 1, 2024
f094540
update steps in README.md
abimichel Feb 1, 2024
d4f44bc
final code clean up
abimichel Feb 1, 2024
9d0fddd
flag all Helm changes with DF-NOTE
abimichel Feb 1, 2024
31cd445
modified: docker-publish-opensearch.yml
abimichel Feb 1, 2024
ac3f2cd
modified: docker-publish-opensearch.yml
abimichel Feb 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/docker-publish-opensearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Push to GHCR

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]


env:
# DF-NOTE: pull ghcr.io/bcgov/nr-openmetadata-opensearch:main
REGISTRY: ghcr.io
DOCKERFILE_PATH: charts/deps/charts/opensearch-2.12.1/containers
IMAGE_NAME: ${{ github.repository }}-opensearch

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
# DF-NOTE: delete after merging PR
with:
ref: security-context-changes

- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v2.1.1'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
# DF-NOTE: to help the action find the Dockerfile to build from
context: ${{ env.DOCKERFILE_PATH }}/
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}

run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts-1.2.4
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ helm uninstall openmetadata-dependencies
```

## Deploying to OpenShift
To deploy to OpenShift, using OC commands make sure Helm cli is installed on your local machine.
To deploy to OpenShift, use OC commands and make sure Helm cli is installed on your local machine.
```
brew install helm
```
Expand All @@ -79,33 +79,48 @@ Source: https://github.com/open-metadata/openmetadata-helm-charts/tree/main/char
```
oc create secret generic airflow-mysql-secrets --from-literal=airflow-mysql-password=airflow_pass
```
#### Add Helm repo to OS
#### Deploy dependencies to OpenShift
Navigate to the 'deps' chart folder then:
```
helm repo add open-metadata https://helm.open-metadata.org
```
#### Deploy dependencies to OS
```
helm install openmetadata-dependencies open-metadata/openmetadata-dependencies
helm install openmetadata-dependencies .
```
If you see the below error then get admin access to the dev namespace
Issues: User "[email protected]" cannot get resource "roles" in API group "rbac.authorization.k8s.io" in the namespace "a1b9b0-dev"

### Install OpenMetadata
Source: https://github.com/open-metadata/openmetadata-helm-charts/tree/main/charts/openmetadata

#### Create default Secrets
```
oc create secret generic mysql-secrets --from-literal=openmetadata-mysql-password=openmetadata_password
oc create secret generic airflow-secrets --from-literal=openmetadata-airflow-password=admin
```
#### Deploy Helm chart
## Apply the pod label policies under 'oc' folder:
```
oc apply -f [auto-label].yaml
```
## Apply the network policies under 'oc' folder:
```
helm install openmetadata-dependencies open-metadata/openmetadata-dependencies --values charts/deps/values.yaml
helm install openmetadata open-metadata/openmetadata --values charts/openmetadata/values.yaml
oc apply -f [net-pol].yaml
```
#### Deploy OpenMetadata to OpenShift:
Navigate to the 'openmetadata' chart folder then:
```
helm install openmetadata .
```
#### Port Forward OpenMetadata to view UI
```

## Creating OpenShift ConfigMaps

## Errors encountered
```

## OpenSearch Dockerfile and Use of GHCR
OpenSearch requires a modified Dockerfile to work within the OpenShift restricted security context. The Dockerfile can be found under charts/opensearch-2.12.1/containers. The image is built automatically and pushed to the GHCR any time there is a push or PR to the **main** branch.

Usage example:
```sh
docker pull ghcr.io/bcgov/nr-openmetadata-opensearch:main
```

create Pod mysql-0 in StatefulSet mysql failed error: pods "mysql-0" is forbidden: unable to validate against any security context constraint: [provider "trident-controller": Forbidden: not usable by user or serviceaccount, provider "anyuid": Forbidden: not usable by user or serviceaccount, provider "pipelines-scc": Forbidden: not usable by user or serviceaccount, provider restricted-v2: .spec.securityContext.fsGroup: Invalid value: []int64{1001}: 1001 is not an allowed group, provider restricted-v2: .containers[0].runAsUser: Invalid value: 1001: must be in the ranges: [1001900000, 1001909999], provider restricted: .spec.securityContext.fsGroup: Invalid value: []int64{1001}: 1001 is not an allowed group, provider restricted: .containers[0].runAsUser: Invalid value: 1001: must be in the ranges: [1001900000, 1001909999], provider "nonroot-v2": Forbidden: not usable by user or serviceaccount, provider "nonroot": Forbidden: not usable by user or serviceaccount, provider "hostmount-anyuid": Forbidden: not usable by user or serviceaccount, provider "elasticsearch-scc": Forbidden: not usable by user or serviceaccount, provider "log-collector-scc": Forbidden: not usable by user or serviceaccount, provider "machine-api-termination-handler": Forbidden: not usable by user or serviceaccount, provider "hostnetwork-v2": Forbidden: not usable by user or serviceaccount, provider "hostnetwork": Forbidden: not usable by user or serviceaccount, provider "hostaccess": Forbidden: not usable by user or serviceaccount, provider "trident-node-linux": Forbidden: not usable by user or serviceaccount, provider "node-exporter": Forbidden: not usable by user or serviceaccount, provider "privileged": Forbidden: not usable by user or serviceaccount]
## Helm chart modifications
To review all Helm chart modifications (i.e. differences between the OpenMetadata default config and this config), search this repo for "DF-NOTE:" annotations.
4 changes: 2 additions & 2 deletions charts/deps/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ type: application
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)

version: 1.2.3
version: 1.2.8

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.2.2"
appVersion: "1.2.5"

home: https://open-metadata.org/

Expand Down
47 changes: 47 additions & 0 deletions charts/deps/charts/airflow-8.8.0/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Patterns to ignore when building the helm package

## Git
.git
.gitignore

## JetBrains
.idea/
*.iml
*.ipr
*.iws

## VSCode
.vscode/*
*.code-workspace
.history/

## Vim
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
Session.vim
Sessionx.vim
.netrwhist
*~
[._]*.un~

## Emacs
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
.\#*

## macOS
.DS_Store
.AppleDouble
.LSOverride
._*

## Chart Documentation
/ci
/docs
/examples
Loading
Loading