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

[wip] Add sync client implementation #243

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ ifeq ($(SYNC_MANAGER),false)
else
SETUP_CMD += "1"
endif
ifeq ($(SYNC_CLIENT),false)
SETUP_CMD += "0"
else
SETUP_CMD += "1"
endif

.PHONY: clean
clean:
Expand All @@ -71,7 +76,7 @@ setup:
############

.PHONY: build
build: build-apiserver build-client build-sync-manager
build: build-apiserver build-client build-sync-manager build-sync-client

.PHONY: build-apiserver
build-apiserver:
Expand All @@ -85,13 +90,17 @@ build-client:
build-sync-manager:
$(GO_BUILD_RECIPE) -o cluster-registry-sync-manager cmd/sync/manager/manager.go

.PHONY: build-sync-client
build-sync-client:
$(GO_BUILD_RECIPE) -o cluster-registry-sync-client cmd/sync/client/client.go

.PHONY: release
release:
./hack/release.sh

.PHONY: image
image: GOOS := linux
image: .hack-apiserver-image .hack-client-image .hack-sync-manager-image
image: .hack-apiserver-image .hack-client-image .hack-sync-manager-image .hack-sync-client-image

.hack-apiserver-image: cmd/apiserver/Dockerfile build-apiserver
docker build -t $(IMAGE_APISERVER):$(TAG) -f cmd/apiserver/Dockerfile .
Expand All @@ -105,6 +114,10 @@ image: .hack-apiserver-image .hack-client-image .hack-sync-manager-image
docker build -t $(IMAGE_SYNC_MANAGER):$(TAG) -f cmd/sync/manager/Dockerfile .
touch $@

.hack-sync-client-image: cmd/sync/client/Dockerfile build-sync-client
docker build -t $(IMAGE_SYNC_CLIENT):$(TAG) -f cmd/sync/client/Dockerfile .
touch $@

.PHONY: update-go-deps
update-go-deps:
for m in $$(go list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
Expand Down
22 changes: 22 additions & 0 deletions charts/cluster-registry-sync-client/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
19 changes: 19 additions & 0 deletions charts/cluster-registry-sync-client/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
name: cluster-registry-sync-client

description: Cluster Registry is a Rest API representing the source of record for
all Kubernetes clusters in the infrastructure fleet. All clusters are automatically
registered, and the information is accurately reflected in the Cluster Registry
using a client-server architecture.

type: application
home: https://github.com/adobe/cluster-registry

maintainers:
- name: aalexandru
email: [email protected]
- name: radu-catalina
email: [email protected]

version: 0.0.1
appVersion: v1.6.5
57 changes: 57 additions & 0 deletions charts/cluster-registry-sync-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# cluster-registry-sync-client

![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v1.6.5](https://img.shields.io/badge/AppVersion-v1.6.5-informational?style=flat-square)

Cluster Registry is a Rest API representing the source of record for all Kubernetes clusters in the infrastructure fleet. All clusters are automatically registered, and the information is accurately reflected in the Cluster Registry using a client-server architecture.

**Homepage:** <https://github.com/adobe/cluster-registry>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| aalexandru | <[email protected]> | |
| radu-catalina | <[email protected]> | |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| clusterRegistrySyncManager.health.healthProbeBindAddress | string | `":8081"` | |
| clusterRegistrySyncManager.leaderElection.leaderElect | bool | `false` | |
| clusterRegistrySyncManager.leaderElection.resourceLock | string | `"leases"` | |
| clusterRegistrySyncManager.leaderElection.resourceName | string | `"sync.registry.ethos.adobe.com"` | |
| clusterRegistrySyncManager.metrics.bindAddress | string | `"0.0.0.0:9090"` | |
| clusterRegistrySyncManager.watchedGVKs | object | `{}` | |
| clusterRegistrySyncManager.webhook.port | int | `9443` | |
| fullnameOverride | string | `"cluster-registry-sync-manager"` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.registry | string | `"ghcr.io/adobe/cluster-registry-sync-manager"` | |
| imagePullSecrets | list | `[]` | |
| livenessProbe.httpGet.path | string | `"/healthz"` | |
| livenessProbe.httpGet.port | int | `9091` | |
| livenessProbe.initialDelaySeconds | int | `15` | |
| livenessProbe.periodSeconds | int | `20` | |
| nameOverride | string | `"cluster-registry-sync-manager"` | |
| podDisruptionBudget.enabled | bool | `true` | |
| podDisruptionBudget.minAvailable | string | `"50%"` | |
| podMonitor.enabled | bool | `false` | |
| podMonitor.extraLabels | object | `{}` | |
| ports[0].containerPort | int | `9090` | |
| ports[0].name | string | `"metrics"` | |
| rbac.create | bool | `true` | |
| readinessProbe.httpGet.path | string | `"/readyz"` | |
| readinessProbe.httpGet.port | int | `9091` | |
| readinessProbe.initialDelaySeconds | int | `5` | |
| readinessProbe.periodSeconds | int | `10` | |
| replicaCount | int | `2` | |
| resources.limits.cpu | string | `"200m"` | |
| resources.limits.memory | string | `"400Mi"` | |
| resources.requests.cpu | string | `"100m"` | |
| resources.requests.memory | string | `"200Mi"` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `"cluster-registry-sync-manager"` | |
| terminationGracePeriodSeconds | int | `10` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)
63 changes: 63 additions & 0 deletions charts/cluster-registry-sync-client/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cluster-registry-sync-client.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "cluster-registry-sync-client.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "cluster-registry-sync-client.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "cluster-registry-sync-client.labels" -}}
helm.sh/chart: {{ include "cluster-registry-sync-client.chart" . }}
{{ include "cluster-registry-sync-client.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
component: cluster-registry
{{- end }}

{{/*
Selector labels
*/}}
{{- define "cluster-registry-sync-client.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cluster-registry-sync-client.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "cluster-registry-sync-client.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "cluster-registry-sync-client.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
36 changes: 36 additions & 0 deletions charts/cluster-registry-sync-client/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "cluster-registry-sync-client.fullname" . }}
labels:
{{- include "cluster-registry-sync-manager.labels" . | nindent 4 }}
rules:
- apiGroups:
- registry.ethos.adobe.com
resources:
- clusters
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- registry.ethos.adobe.com
resources:
- clusters/finalizers
verbs:
- update
- apiGroups:
- registry.ethos.adobe.com
resources:
- clusters/status
verbs:
- get
- patch
- update
{{- with .Values.extraRBAC }}
{{- toYaml . | nindent 2 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "cluster-registry-sync-client.fullname" . }}
labels:
{{- include "cluster-registry-sync-client.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-registry-sync-client
subjects:
- kind: ServiceAccount
name: {{ include "cluster-registry-sync-client.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
87 changes: 87 additions & 0 deletions charts/cluster-registry-sync-client/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
{{- include "cluster-registry-sync-client.labels" . | nindent 4 }}
name: {{ include "cluster-registry-sync-client.fullname" . }}
namespace: {{ .Release.Namespace }}
spec:
replicas: {{ .Values.replicaCount | required ".Values.replicaCount is required" }}
selector:
matchLabels:
{{- include "cluster-registry-sync-client.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "cluster-registry-sync-client.selectorLabels" . | nindent 8 }}
annotations:
kubectl.kubernetes.io/default-container: sync-client
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- args:
- --namespace={{ .Release.Namespace }}
{{- if .Values.clusterRegistrySyncClient.health.bindAddress }}
- --health-probe-bind-address={{ .Values.clusterRegistrySyncClient.health.bindAddress }}
{{- end }}
command:
- /bin/sync-client
image: "{{ .Values.image.registry }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
{{- toYaml .Values.ports | nindent 12 }}
env:
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
key: AWS_ACCESS_KEY_ID
name: cluster-registry-aws
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
key: AWS_SECRET_ACCESS_KEY
name: cluster-registry-aws
- name: SQS_ENDPOINT
valueFrom:
secretKeyRef:
key: SQS_ENDPOINT
name: cluster-registry-aws
- name: SQS_QUEUE_NAME
valueFrom:
secretKeyRef:
key: SQS_QUEUE_NAME
name: cluster-registry-aws
- name: AWS_REGION
valueFrom:
secretKeyRef:
key: SQS_AWS_REGION
name: cluster-registry-aws
- name: SQS_AWS_REGION
valueFrom:
secretKeyRef:
key: SQS_AWS_REGION
name: cluster-registry-aws
{{- if .Values.livenessProbe }}
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
{{- end }}
{{- if .Values.readinessProbe }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
{{- end }}
{{- if .Values.resources }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- end }}
name: sync-client
securityContext:
allowPrivilegeEscalation: false
volumes:
- name: {{ include "cluster-registry-sync-client.fullname" . }}-config
configMap:
name: {{ include "cluster-registry-sync-client.fullname" . }}-config
serviceAccountName: {{ include "cluster-registry-sync-client.serviceAccountName" . }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds | required ".Values.terminationGracePeriodSeconds is required" }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.podDisruptionBudget.enabled }}
{{- $isPercentage := regexMatch "^[0-9]+%$" (.Values.podDisruptionBudget.minAvailable | quote) }}
{{- if and (not $isPercentage) (le (.Values.replicaCount | int) (.Values.podDisruptionBudget.minAvailable | int)) }}
{{- fail ".Values.replicaCount should be greater than .Values.podDisruptionBudget.minAvailable" }}
{{- else }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
labels:
{{- include "cluster-registry-sync-client.labels" . | nindent 4 }}
name: {{ include "cluster-registry-sync-client.fullname" . }}
namespace: {{ .Release.Namespace }}
spec:
selector:
matchLabels:
{{- include "cluster-registry-sync-client.selectorLabels" . | nindent 6 }}
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
{{- end }}
{{- end }}
Loading