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

Dat feat awsmp sleek rebase #193

Draft
wants to merge 85 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
e7990ea
feat: new chart for aws marketplace product. The product supports lic…
Sep 6, 2022
6397cdd
fix: qoute productSKU value; add logs for checkout license
Sep 6, 2022
b658876
refactor: upgrade values.yaml with updated image pushed to aws mp pro…
Sep 6, 2022
0640270
fix: support region, product, fingerprint and debug env variables; re…
Sep 7, 2022
fdc41c2
fix: run license cron job on @daily. fix values naming bug
Sep 7, 2022
8ebf020
fix: upgrade image in aws mp helm chart values
Sep 7, 2022
17e6251
fix: remove awsmp-... chart. datree-admission-webhook chart should ho…
Sep 12, 2022
e0a348b
fix: add * to ignore luanch.json file
Sep 12, 2022
5289408
fix: remove ** to ignore luanch.json file
Sep 12, 2022
275e001
fix: accidently deleted gh-pages values file with awsmp values file. …
Sep 21, 2022
eeaa96b
fix: added aws.values
Sep 21, 2022
5e73163
feat: added validation for value.yaml file
Sep 12, 2022
2abeacc
fix: combine charts and added values.yaml for each option
Sep 19, 2022
cc12656
feat: script for packaing
Sep 19, 2022
2ccc1f3
fix: added script package for free-datree
Sep 19, 2022
595a75e
feat: added chart
Sep 20, 2022
42fbd5e
feat: charts file structure
Sep 20, 2022
f896fba
fix: combine charts and added values.yaml for each option
Sep 19, 2022
6489875
feat: script for packaing
Sep 19, 2022
150fba7
fix: added script package for free-datree
Sep 19, 2022
002513b
feat: added chart
Sep 20, 2022
f650e64
fix: move tempaltes to lib template
shmu3l Sep 28, 2022
448011f
fix: remove templates use include from lib
shmu3l Sep 28, 2022
b43ef0f
fix: remove templates use include from lib
shmu3l Sep 28, 2022
771c57a
fix: add dynamic webhook server alt name to cert
shmu3l Oct 2, 2022
2002a8d
fix: clear datree webhook values and update schema
shmu3l Oct 2, 2022
9b446e7
feat: awsmp datree use datree lib
shmu3l Oct 2, 2022
af85f57
fix: awsmp file structure
shmu3l Oct 2, 2022
d1ef809
feat: add release admission webhook script
shmu3l Oct 3, 2022
121763b
fix: release admission webhook
shmu3l Oct 3, 2022
37a828d
release chart 0.1.3
shmu3l Oct 3, 2022
8ddb66f
fix: release admission webhook helm script update
shmu3l Oct 6, 2022
23a42d7
fix: update .gitignore
Oct 6, 2022
30c96e4
fix: change messages
Oct 6, 2022
572c8c5
fix: release admission webhook path scripts
shmu3l Oct 6, 2022
a13fabc
fix: release admission webhook path scripts
shmu3l Oct 6, 2022
57a809a
fix: release admission webhook path scripts
shmu3l Oct 6, 2022
b79e351
fix: rename script
Oct 6, 2022
edfa70f
fix: change the order of helm file creations
Oct 6, 2022
88d5416
fix: remove files
Oct 6, 2022
7e60bf9
fix: release file index yaml
Oct 6, 2022
2d54188
fix: dont stash pop
Oct 6, 2022
56e619f
feat: certificate alternative names use datree.namespace template.
Oct 18, 2022
c02ba66
fix: bump lib chart version
Oct 18, 2022
7132337
fix: added dynamic namespace installation. Rename chart according to …
Oct 24, 2022
883f25c
fix: aligned charts with aws-marketplace ECR repositories.
Nov 3, 2022
d4c0867
feat: pull bitnami-kubectl from private ecr registry
Nov 3, 2022
a09986d
fix: updated bitnami in free offer chart
Nov 3, 2022
378ef6a
feat: added new binary in cmd folder for init container
Nov 7, 2022
a5e0e21
wip
Nov 8, 2022
7d9411c
wip: poc of webhook race condition
Nov 9, 2022
076b597
fix: working product on minikube. NOTE: very slow
Nov 10, 2022
d4cd131
fix: working version
Nov 13, 2022
a1d8ba3
fix: wokring production version on minikube
Nov 13, 2022
4e504da
fix: working production version. Minikube. 3minutes sleep time
Nov 13, 2022
956b584
fix: working version ECR repositories on Faragate.
Nov 13, 2022
3cfe527
feat: support uninstall Datree product
Nov 13, 2022
d2eab5f
fix: working version in AWS Marketplace. Datree product
Nov 13, 2022
58e430c
feat: working version. Datree Free product. version 1.0.1-rc.1
Nov 13, 2022
7ba108f
feat: check for webhook existence, wait for running pods. Refactor
Nov 15, 2022
1f1d134
fix: wait for all deployment replicas to be ready. updated ecr images
Nov 15, 2022
07f0a82
fix: update aws mp Chart
Nov 16, 2022
d51dfde
fix: remove .vscode luanch.json
Nov 16, 2022
cb90d7b
fix: update Dockerfiles
Nov 16, 2022
c3a79b2
fix: remove comments
Nov 16, 2022
09fc506
test: added tests for cert-generator
Nov 16, 2022
f5593a7
test: wip
Nov 20, 2022
4ccf30e
test: fixed table testing for k8sClient
Nov 20, 2022
8161364
test: cert-generator tests
Nov 21, 2022
1e4697b
fix: structure packages in webhook-init to not use one another, only …
Nov 21, 2022
a550115
fix: updated makefile
Nov 21, 2022
52ce8b7
test: ensure empty env variables has defaults
Nov 21, 2022
4b57836
fix: bump images versions, working product on minikube.
Nov 21, 2022
f893b31
fix: make code build succesfully
Nov 21, 2022
b3867fe
fix: fix import position to remove changes
Nov 21, 2022
93c7cd2
fix: remove unused script
Nov 21, 2022
5f8e5ee
fix: remove unnessecary changes in gitignore
Nov 21, 2022
c0a13b7
fix: remove luanch.json
Nov 21, 2022
55bacc5
fix: merge manifests conflicts
Nov 22, 2022
e8a9f87
fix: user logger correctly
Nov 22, 2022
3dbba7d
fix: pass env var for webhook pods selector
Nov 22, 2022
65fe7f0
test: test main flow of cer-generator
Nov 22, 2022
8ecc47c
fix: added deploy in makefile
Nov 27, 2022
7f36170
fix: bump images version in chart
Nov 27, 2022
9938af2
fix Makefile to deploy all binaries for awsmp. Ensure TOKEN isnt requ…
Nov 27, 2022
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
Next Next commit
feat: new chart for aws marketplace product. The product supports lic…
…ense checkout and option to replicate the chart for free product
  • Loading branch information
Noaa Barki authored and Noaa Barki committed Nov 21, 2022
commit e7990ea912a80211a165417db99c4f99fab3c890
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
},
{
"name": "staging",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"args": ["upgrade"],
"buildFlags": "-tags=staging",
"env": {
"AWS_MP_ENABLE_CHECKOUT_LICENSE": "true",
"AWS_MP_PRODUCT_SKU": "ad0ee0c8-f50f-464a-9bc4-d6270592dd36"
}
}
]
}
26 changes: 26 additions & 0 deletions charts/awsmp-datree-admission-webhook/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v2
name: awsmp-datree-admission-webhook
description: A Helm chart for Datree admission webhook for Kubernetes clusters
icon: https://github.com/datreeio/admission-webhook-datree/blob/main/internal/images/diagram.png
type: application
keywords:
- awsmp-datree-admission-webhook
- policy agent
- validating webhook
- admissions controller
home: datree.io
sources:
- https://github.com/datreeio/admission-webhook-datree

kubeVersion: ">=1.16.0-0"

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# 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: "0.1.21"
62 changes: 62 additions & 0 deletions charts/awsmp-datree-admission-webhook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Datree Admission Webhook

A Kubernetes validating webhook for policy enforcement within the cluster, on every CREATE, APPLY and UPDATE operation on a resource.

## TL;DR

```bash
# Install and create namespace with Helm
helm repo add datree-webhook https://datreeio.github.io/admission-webhook-datree/
helm repo update

# Already existing `datree` namespace
kubectl create ns datree
helm install -n datree datree-webhook datree-webhook/datree-admission-webhook --set datree.token=<DATREE_TOKEN>
```

### Prerequisites

Helm v3.0.0+

## Configuration Options

Datree admission webhook can be configured via the helm values file under `datree` key:

### Datree Configuration options

```
datree:
token: <DATREE_TOKEN> # The token used to link the CLI to your dashboard.
policy: "" # The name of the policy to check, e.g: staging. (string, optional)
verbose: "" # Display 'How to Fix' link for failed rules in output. (boolean ,optional)
output: "" # The format output of the policy check results: yaml, json, xml, simple, JUnit. (string ,optional)
noRecord: "" # Don’t send policy checks metadata to the backend. (boolean ,optional)
```

For further information about Datree flags see [CLI arguments](https://hub.datree.io/setup/cli-arguments).

### Parameters

| Parameter | Description | Default | | |
| ------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --- | --- |
| namespace | The name of the namespace all resources will be created in. | datree | | |
| replicaCount | The number of Datree webhook-server replicas to deploy for the webhook. | 2 | | |
| customLabels | Additional labels for Datree webhook-server pods. | {} | | |
| customAnnotations | Additional annotations to add to all resources. | {} | | |
| rbac.serviceAccount.create | Create a ServiceAccount | true | | |
| rbac.serviceAccount.name | The ServiceAccount name | webhook-server-datree | | |
| rbac.clusterRole.create | Create a ClusterRole | true | | |
| rbac.clusterRole.name | The ClusterRole name | webhook-server-datree | | |
| image.repository | Image repository. | datree/admission-webhook | | |
| image.tag | The image release tag to use. | Defaults to Chart appVersion | | |
| image.pullPolicy | Image pull policy | Always | | |
| securityContext | Security context applied on the container. | {"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true, "runAsNonRoot":true,"runAsUser":25000} | | |
| resources | The resource request/limits for the container image. | limits :cpu: 1000m, memory: 512Mi requests: cpu:100m, memory:256Mi | | |
| datree.token | The token used to link the CLI to your dashboard. (required) | nil | | |
| datree.policy | The name of the policy to check, e.g: staging. (optional) | "" (i.e "default") | | |
| datree.verbose | Display 'How to Fix' link for failed rules in output. (optional) | false | | |
| datree.output | The format output of the policy check results: yaml, json, xml, simple, JUnit. (optional) | "" (i.e beautiful😊) | | |
| datree.noRecord | Don’t send policy checks metadata to the backend. (optional) | false | | |
| hooks.waitForServerRollout.sleepyTime | The waiting time before the webhook-server is ready to receive requests. | nil | | |
| hooks.waitForServerRollout.image | An image for running sleep command | {"repository": "alpine", "sha":"sha256:1304f174557314a7ed9eddb4eab12fed12cb0cd9809e4c28f29af86979a3c870", "pullPolicy":"Always"} | | |
| hooks.labelNamespace.image. | An image for running kubectl label command | {"repository": "bitnami/kubectl", "sha":"sha256:d3c17f1dc6e665dcc78e8c14a83ae630bc3d65b07ea11c5f1a012c2c6786d039", "pullPolicy":"Always"} | | |
25 changes: 25 additions & 0 deletions charts/awsmp-datree-admission-webhook/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{/* Create chart name and version as used by the chart label. */}}
{{- define "datree.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}


{{/* Helm and Kubernetes required labels */}}
{{- define "datree.labels" -}}
app.kubernetes.io/name: {{.Chart.Name}}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
app.kubernetes.io/part-of: "datree"
meta.helm.sh/release-name: "{{ .Chart.Name }}"
meta.helm.sh/release-namespace: "{{ .Release.Namespace}}"
helm.sh/chart: {{ template "datree.chart" . }}
{{- if .Values.customLabels -}}
{{ toYaml .Values.customLabels }}
{{- end -}}
{{- end -}}

{{/* The namespace name. */}}
{{- define "datree.namespace" -}}
{{- default .Release.Namespace .Values.namespace -}}
{{- end -}}
64 changes: 64 additions & 0 deletions charts/awsmp-datree-admission-webhook/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{- if .Values.rbac.clusterRole.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{.Values.rbac.clusterRole.name}}
labels: {{ include "datree.labels" . | nindent 4 }}
{{- if .Values.customAnnotations }}
annotations: {{- toYaml .Values.customAnnotations | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- ""
resources:
- "nodes"
- "namespaces"
verbs:
- "get"
- "list"
{{- end}}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: datree-namespaces-update
labels: {{include "datree.labels" . | nindent 4}}
{{- if .Values.customAnnotations }}
annotations: {{- toYaml .Values.customAnnotations | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- update
- patch
resourceNames:
- kube-system
- {{template "datree.namespace" .}}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: datree-validationwebhook-delete
labels: {{include "datree.labels" . | nindent 4}}
{{- if .Values.customAnnotations }}
annotations: {{- toYaml .Values.customAnnotations | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- "admissionregistration.k8s.io"
resources:
- validatingwebhookconfigurations
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
resourceNames:
- datree-webhook
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{- if .Values.rbac.clusterRole.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{.Values.rbac.clusterRole.name}}
labels: {{include "datree.labels" . | nindent 4}}
{{- if .Values.customAnnotations }}
annotations: {{- toYaml .Values.customAnnotations | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{.Values.rbac.clusterRole.name}} # datree-webhook-server-read
subjects:
- kind: ServiceAccount
name: {{.Values.rbac.serviceAccount.name}} # datree-webhook-server
namespace: {{template "datree.namespace" .}}
---
{{- end }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: datree-namespaces-update
labels: {{include "datree.labels" . | nindent 4}}
{{- if .Values.customAnnotations }}
annotations: {{- toYaml .Values.customAnnotations | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: datree-namespaces-update
subjects:
- kind: ServiceAccount
name: "datree-label-namespaces-hook-post-install"
namespace: "{{template "datree.namespace" .}}"
- kind: ServiceAccount
name: "datree-cleanup-namespaces-hook-pre-delete"
namespace: "{{template "datree.namespace" .}}"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: datree-validationwebhook-delete
labels: {{include "datree.labels" . | nindent 4}}
{{- if .Values.customAnnotations }}
annotations: {{- toYaml .Values.customAnnotations | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: datree-validationwebhook-delete
subjects:
- kind: ServiceAccount
name: "datree-cleanup-namespaces-hook-pre-delete"
namespace: "{{template "datree.namespace" .}}"
92 changes: 92 additions & 0 deletions charts/awsmp-datree-admission-webhook/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: datree-webhook-server
namespace: {{ template "datree.namespace" . }}
labels: {{ include "datree.labels" . | nindent 4 }}
owner: datree
app: "datree-webhook-server"
{{- if .Values.customAnnotations }}
annotations: {{- toYaml .Values.customAnnotations | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: "datree-webhook-server"
template:
metadata:
labels: {{ include "datree.labels" . | nindent 8 }}
app: "datree-webhook-server"
{{- if .Values.customAnnotations }}
annotations: {{- toYaml .Values.customAnnotations | nindent 4 }}
{{- end }}
spec:
serviceAccountName: {{.Values.rbac.serviceAccount.name}}
containers:
- name: server
securityContext: {{- toYaml .Values.securityContext | nindent 12 }}
livenessProbe:
httpGet:
path: /health
port: 8443
scheme: HTTPS
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8443
scheme: HTTPS
initialDelaySeconds: 5
periodSeconds: 10
resources: {{- toYaml .Values.resources | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{.Values.image.pullPolicy}}
ports:
- containerPort: 8443
name: webhook-api
# caution: don't change the order of the environment variables
# changing the order will harm resource patching
env:
- name: DATREE_TOKEN
value: {{.Values.datree.token}}
- name: DATREE_POLICY
value: {{.Values.datree.policy}}
- name: DATREE_VERBOSE
value: {{.Values.datree.verbose}}
- name: DATREE_OUTPUT
value: {{.Values.datree.output}}
- name: DATREE_NO_RECORD
value: {{.Values.datree.noRecord}}
- name: AWS_MP_PRODUCT_SKU
value: {{.Values.aws.productSku}}
- name: AWS_MP_ENABLE_CHECKOUT_LICENSE
value: {{.Values.aws.enableCheckoutLicense}}
{{- if .Values.aws.mpLicenseSecretName }}
- name: AWS_WEB_IDENTITY_REFRESH_TOKEN_FILE
value: "/var/run/secrets/awsmp-product-license/license_token"
- name: AWS_ROLE_ARN
valueFrom:
secretKeyRef:
name: {{ .Values.aws.mpLicenseSecretName }}
key: iam_role
{{- end}}
# add aws marketplace license config to the licensed container application env
volumeMounts:
- name: webhook-tls-certs
mountPath: /run/secrets/tls
readOnly: true
{{- if .Values.aws.mpLicenseSecretName }}
- name: awsmp-product-license
mountPath: "/var/run/secrets/awsmp-product-license"
{{- end}}
volumes:
- name: webhook-tls-certs
secret:
secretName: webhook-server-tls
{{- if .Values.aws.mpLicenseSecretName }}
- name: awsmp-product-license
secret:
secretName: {{ .Values.aws.mpLicenseSecretName }}
{{- end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: batch/v1
kind: Job
metadata:
name: datree-cleanup-namespaces-hook-pre-delete
labels: {{include "datree.labels" . | nindent 4}}
namespace: {{template "datree.namespace" .}}
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded, hook-failed
{{- if .Values.customAnnotations }}
{{- toYaml .Values.customAnnotations }}
{{- end }}
spec:
template:
metadata:
labels: {{include "datree.labels" . | nindent 8}}
{{- if .Values.customAnnotations }}
annotations: {{- toYaml .Values.customAnnotations | nindent 4 }}
{{- end }}
spec:
restartPolicy: OnFailure
serviceAccount: datree-cleanup-namespaces-hook-pre-delete
nodeSelector:
kubernetes.io/os: linux
containers:
- name: kubectl-label
image: "{{ .Values.hooks.image.repository }}@{{ .Values.hooks.image.sha }}"
imagePullPolicy: {{.Values.hooks.image.pullPolicy}}
command:
- sh
- "-c"
- >-
kubectl delete validatingwebhookconfigurations.admissionregistration.k8s.io datree-webhook -n {{template "datree.namespace" .}};
kubectl label ns kube-system {{template "datree.namespace" .}} datree.io/skip-;
Loading
Oops, something went wrong.