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

feat: AWS marketplace & EKS add on integration (WIP) #86

Open
wants to merge 81 commits into
base: main
Choose a base branch
from
Open
Changes from 68 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
5842bac
feat: new chart for aws marketplace product. The product supports lic…
Sep 6, 2022
fbc595c
fix: qoute productSKU value; add logs for checkout license
Sep 6, 2022
20852b4
refactor: upgrade values.yaml with updated image pushed to aws mp pro…
Sep 6, 2022
ed91e2a
fix: support region, product, fingerprint and debug env variables; re…
Sep 7, 2022
44b1b82
fix: run license cron job on @daily. fix values naming bug
Sep 7, 2022
4012723
fix: upgrade image in aws mp helm chart values
Sep 7, 2022
0ae52ee
fix: remove awsmp-... chart. datree-admission-webhook chart should ho…
Sep 12, 2022
f61c9c7
fix: add * to ignore luanch.json file
Sep 12, 2022
32e1e4e
fix: remove ** to ignore luanch.json file
Sep 12, 2022
754366a
feat: added validation for value.yaml file
Sep 12, 2022
2beb9fa
fix: combine charts and added values.yaml for each option
Sep 19, 2022
cd9ef82
feat: script for packaing
Sep 19, 2022
17d8e07
fix: added script package for free-datree
Sep 19, 2022
3b5fa6d
feat: added chart
Sep 20, 2022
5ca2d41
fix: accidently deleted gh-pages values file with awsmp values file. …
Sep 21, 2022
be37723
fix: added aws.values
Sep 21, 2022
916151b
feat: added validation for value.yaml file
Sep 12, 2022
7dcfbbe
fix: combine charts and added values.yaml for each option
Sep 19, 2022
80c87f7
feat: script for packaing
Sep 19, 2022
8cc5a94
fix: added script package for free-datree
Sep 19, 2022
33758ae
feat: added chart
Sep 20, 2022
2eb9637
feat: charts file structure
Sep 20, 2022
7e86a32
fix: move tempaltes to lib template
shmu3l Sep 28, 2022
538ff06
Merge branch 'datree-lib-chart' into DAT-feat-datree-lib-chart
shmu3l Sep 28, 2022
ebab8d6
fix: remove templates use include from lib
shmu3l Sep 28, 2022
9002818
fix: remove templates use include from lib
shmu3l Sep 28, 2022
25ced28
fix: add dynamic webhook server alt name to cert
shmu3l Oct 2, 2022
c7eb9ae
fix: clear datree webhook values and update schema
shmu3l Oct 2, 2022
3a92aac
feat: awsmp datree use datree lib
shmu3l Oct 2, 2022
dc2b784
Merge pull request #99 from datreeio/DAT-awsmp-datree-use-lib
shmu3l Oct 2, 2022
31214ab
fix: awsmp file structure
shmu3l Oct 2, 2022
91ff33e
feat: add release admission webhook script
shmu3l Oct 3, 2022
a3f36c9
fix: release admission webhook
shmu3l Oct 3, 2022
3fa719e
fix: bump chart version
shmu3l Oct 3, 2022
68d2b7f
release chart 0.1.3
shmu3l Oct 3, 2022
9d53630
fix: release admission webhook helm script update
shmu3l Oct 6, 2022
4e8ef26
fix: update .gitignore
Oct 6, 2022
a7c79e8
fix: change messages
Oct 6, 2022
5f2fe54
fix: release admission webhook path scripts
shmu3l Oct 6, 2022
4a16912
fix: release admission webhook path scripts
shmu3l Oct 6, 2022
0aefb7b
fix: release admission webhook path scripts
shmu3l Oct 6, 2022
eb6f8e5
fix: rename script
Oct 6, 2022
ffbccfb
fix: change the order of helm file creations
Oct 6, 2022
6b7605e
fix: remove files
Oct 6, 2022
121fc8c
fix: release file index yaml
Oct 6, 2022
e775214
fix: dont stash pop
Oct 6, 2022
27c833d
feat: certificate alternative names use datree.namespace template.
Oct 18, 2022
5c19e06
fix: bump lib chart version
Oct 18, 2022
3c9e662
Merge pull request #142 from datreeio/DAT-support-certificate-release…
noaabarki Oct 18, 2022
d9dd178
fix: added dynamic namespace installation. Rename chart according to …
Oct 24, 2022
890d179
fix: aligned charts with aws-marketplace ECR repositories.
Nov 3, 2022
19585b5
feat: pull bitnami-kubectl from private ecr registry
Nov 3, 2022
4e04618
fix: updated bitnami in free offer chart
Nov 3, 2022
49aff40
feat: added new binary in cmd folder for init container
Nov 7, 2022
6930693
wip
Nov 8, 2022
c08df99
wip: poc of webhook race condition
Nov 9, 2022
6055484
fix: working product on minikube. NOTE: very slow
Nov 10, 2022
8d1eb85
fix: working version
Nov 13, 2022
976d208
fix: wokring production version on minikube
Nov 13, 2022
89e7bda
fix: working production version. Minikube. 3minutes sleep time
Nov 13, 2022
674558d
fix: working version ECR repositories on Faragate.
Nov 13, 2022
b986d9b
feat: support uninstall Datree product
Nov 13, 2022
8fd5105
fix: working version in AWS Marketplace. Datree product
Nov 13, 2022
790d488
feat: working version. Datree Free product. version 1.0.1-rc.1
Nov 13, 2022
332ecbd
feat: check for webhook existence, wait for running pods. Refactor
Nov 15, 2022
14277c3
fix: wait for all deployment replicas to be ready. updated ecr images
Nov 15, 2022
811dd1b
fix: update aws mp Chart
Nov 16, 2022
5e6d6d7
fix: remove .vscode luanch.json
Nov 16, 2022
acc7591
fix: update Dockerfiles
Nov 16, 2022
64eb1c5
fix: remove comments
Nov 16, 2022
04ace8c
Merge pull request #179 from datreeio/DAT-custom-validation-webhook
noaabarki Nov 16, 2022
b2999c6
test: added tests for cert-generator
Nov 16, 2022
1c47849
test: wip
Nov 20, 2022
74e9c60
test: fixed table testing for k8sClient
Nov 20, 2022
feb8e8d
test: cert-generator tests
Nov 21, 2022
c766a92
fix: structure packages in webhook-init to not use one another, only …
Nov 21, 2022
43a6ea2
fix: updated makefile
Nov 21, 2022
3c0a416
test: ensure empty env variables has defaults
Nov 21, 2022
ddeddfd
fix: bump images versions, working product on minikube.
Nov 21, 2022
0c9ca9d
Merge pull request #92 from datreeio/DAT-feat-datree-lib-chart
noaabarki Nov 21, 2022
08bef3a
Merge pull request #91 from datreeio/DAT-chart-values-validation
noaabarki Nov 21, 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -6,4 +6,6 @@

webhook-datree

.idea/*

.DS_STORE
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// 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": []
}
19 changes: 0 additions & 19 deletions Dockerfile

This file was deleted.

122 changes: 102 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,112 @@
start-watch:
gow run -tags $(or $(datree_build_env),staging) -ldflags="-X github.com/datreeio/admission-webhook-datree/pkg/config.WebhookVersion=0.0.1" main.go

start:
go run -tags $(or $(datree_build_env),staging) -ldflags="-X github.com/datreeio/admission-webhook-datree/pkg/config.WebhookVersion=0.0.1" main.go
start-dev:
make datree_build_env=dev start
start-staging:
make datree_build_env=staging start
start-production:
make datree_build_env=main start

build:
go build -tags $(or $(datree_build_env),staging) -ldflags="-X github.com/datreeio/admission-webhook-datree/pkg/config.WebhookVersion=0.0.1" -o webhook-datree
build-dev:
make datree_build_env=dev build
build-staging:
make datree_build_env=staging build
build-production:
make datree_build_env=main build

#################
# DEFAULTS #
#################

CMD_DIR := ./cmd
INIT_WEBHOOK_DIR := $(CMD_DIR)/init-webhook
CERT_GENERATOR_DIR := $(CMD_DIR)/cert-generator
WEBHOOK_SERVER_DIR := $(CMD_DIR)/webhook-server
WEBHOOK_VERSION := 0.0.1
LD_FLAGS := "-X github.com/datreeio/admission-webhook-datree/pkg/config.WebhookVersion=$(WEBHOOK_VERSION)"
BUILD_ARGS_ENV ?= staging
BUILD_ARGS_DIR ?= $(WEBHOOK_SERVER_DIR)
BUILD_ARGS_OUTPUT ?= webhook-server

#################
# BUILD CODE #
#################
_builder:
go build -o ${BUILD_ARGS_OUTPUT} -tags ${BUILD_ARGS_ENV} -ldflags=$(LD_FLAGS) $(BUILD_ARGS_DIR)

build-cert-generator-%:
$(MAKE) _builder \
-e BUILD_ARGS_DIR=$(CERT_GENERATOR_DIR) \
-e BUILD_ARGS_ENV="$*" \
-e BUILD_ARGS_OUTPUT="cert-generator"

build-init-webhook-%:
$(MAKE) _builder \
-e BUILD_ARGS_DIR=$(INIT_WEBHOOK_DIR) \
-e BUILD_ARGS_ENV="$*" \
-e BUILD_ARGS_OUTPUT="init-webhook"

build-webhook-server-%:
$(MAKE) _builder \
-e BUILD_ARGS_DIR=$(WEBHOOK_SERVER_DIR) \
-e BUILD_ARGS_ENV="$*" \
-e BUILD_ARGS_OUTPUT="webhook-server"

#################
# RUN #
#################

_runner:
go run -tags ${BUILD_ARGS_ENV} -ldflags=$(LD_FLAGS) $(BUILD_ARGS_DIR)

run-cert-generator-%:
$(MAKE) _runner \
-e BUILD_ARGS_DIR=$(CERT_GENERATOR_DIR) \
-e BUILD_ARGS_ENV="$*"

run-init-webhook-%:
$(MAKE) _runner \
-e BUILD_ARGS_DIR=$(INIT_WEBHOOK_DIR) \
-e BUILD_ARGS_ENV="$*"

run-webhook-server-%:
$(MAKE) _runner \
-e BUILD_ARGS_DIR=$(WEBHOOK_SERVER_DIR) \
-e BUILD_ARGS_ENV="$*"



#################
# TEST #
#################

test:
go test ./...


##################
# BUILD IMAGE #
##################
_image_builder:
docker build -t ${BUILD_ARGS_OUTPUT} -f $(BUILD_ARGS_DIR)/Dockerfile . --build-arg BUILD_ENVIRONMENT=${BUILD_ARGS_ENV}

build-image-cert-generator-%:
$(MAKE) _image_builder \
-e BUILD_ARGS_DIR=$(CERT_GENERATOR_DIR) \
-e BUILD_ARGS_ENV="$*" \
-e BUILD_ARGS_OUTPUT="cert-generator"

build-image-init-webhook-%:
$(MAKE) _image_builder \
-e BUILD_ARGS_DIR=$(INIT_WEBHOOK_DIR) \
-e BUILD_ARGS_ENV="$*" \
-e BUILD_ARGS_OUTPUT="init-webhook"

build-image-webhook-server-%:
$(MAKE) _image_builder \
-e BUILD_ARGS_DIR=$(WEBHOOK_SERVER_DIR) \
-e BUILD_ARGS_ENV="$*" \
-e BUILD_ARGS_OUTPUT="webhook-server"

#################
# DEPLOY #
#################

.PHONY: deploy-in-minikube
deploy-in-minikube:
bash ./scripts/deploy-in-minikube.sh

.PHONY: run-in-minikube
run-in-minikube:
bash ./scripts/run-in-minikube.sh

.PHONY: test-in-minikube
test-in-minikube:
bash ./scripts/test-in-minikube.sh

# to be continued...
6 changes: 6 additions & 0 deletions charts/datree-admission-webhook-awsmp/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: datree-lib
repository: file://../datree-lib
version: 0.1.1
digest: sha256:a65b157f4e3e466bfc9a80df08a319a3f61abdb84e4a29dfbe18127dd11edac6
generated: "2022-10-18T15:06:55.309464+03:00"
31 changes: 31 additions & 0 deletions charts/datree-admission-webhook-awsmp/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v2
name: datree-admission-webhook-awsmp
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:
- 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: 1.0.2-rc.1

# 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.24-rc.2"

dependencies:
- name: datree-lib
version: 0.1.1
repository: file://../datree-lib
Binary file not shown.
25 changes: 25 additions & 0 deletions charts/datree-admission-webhook-awsmp/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 -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- include "datree-lib.clusterrole" .}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- include "datree-lib.clusterrolebinding" .}}
130 changes: 130 additions & 0 deletions charts/datree-admission-webhook-awsmp/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
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"
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-weight": "5"
{{- if .Values.customAnnotations }}
{{- 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: webhook-init
image: "{{ .Values.imageWebhook.repository }}:{{ .Values.imageWebhook.tag | default .Chart.AppVersion }}"
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /etc/webhook/certs
name: webhook-certs
env:
- name: WEBHOOK_NAMESPACE
value: {{ template "datree.namespace" . }}
- name: WEBHOOK_SERVICE
value: "datree-webhook-server"
- name: WEBHOOK_SELECTOR
value: "admission.datree/validate"
- name: WEBHOOK_SERVER_REPLICAS
value: "{{ .Values.replicaCount }}"
- 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: DEBUG
value: "{{ .Values.debug }}"
# Datree webhook varaibles
- 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}}
# AWS Marketplace varaibles
- name: AWS_MP_PRODUCT_ID
value: {{ .Values.aws.productId }}
- name: AWS_MP_KEY_FINGERPRINT
value: {{ .Values.aws.issuerKey }}
- name: AWS_MP_ENABLE_CHECK_ENTITLEMENT
value: "{{.Values.aws.enableCheckEntitlement}}"
- name: AWS_MP_REGION
value: {{.Values.aws.region}}
{{- if .Values.aws.licenseConfigSecretName }}
- 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.licenseConfigSecretName }}
key: iam_role
{{- end}}
# add aws marketplace license config to the licensed container application env
volumeMounts:
- mountPath: /etc/webhook/certs
name: webhook-certs
readOnly: true
{{- if .Values.aws.licenseConfigSecretName }}
- name: awsmp-product-license
mountPath: "/var/run/secrets/awsmp-product-license"
{{- end}}
volumes:
- name: webhook-certs
emptyDir: {}
{{- if .Values.aws.licenseConfigSecretName }}
- name: awsmp-product-license
secret:
secretName: {{ .Values.aws.licenseConfigSecretName }}
{{- end}}
initContainers:
- name: generate-cert
image: "{{ .Values.initContainer.repository }}:{{ .Values.initContainer.tag }}"
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /etc/webhook/certs
name: webhook-certs
env:
- name: WEBHOOK_CERTS_DIR
value: /etc/webhook/certs
- name: WEBHOOK_SERVER_DNS
value: {{ printf "datree-webhook-server.%s.svc" (include "datree.namespace" .)}}

Loading
Oops, something went wrong.