Skip to content

Commit

Permalink
Add yorkie-cluster helm chart for k8s environment
Browse files Browse the repository at this point in the history
  • Loading branch information
krapie committed Feb 9, 2024
1 parent e37ac6f commit 288ca1d
Show file tree
Hide file tree
Showing 21 changed files with 493 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
build:
.PHONY build:
CGO_ENABLED=0 go build -o ./bin/plumber .

docker-build:
.PHONY docker-build:
docker build --push -t krapi0314/plumber .

docker-compose-up:
.PHONY docker-compose-up:
docker-compose -f ./docker/docker-compose.yml up --build -d

docker-compose-down:
.PHONY docker-compose-down:
docker-compose -f ./docker/docker-compose.yml down

docker-compose-yorkie-up:
.PHONY docker-compose-yorkie-up:
docker-compose -f ./docker/docker-compose-yorkie.yml up --build -d

docker-compose-yorkie-down:
.PHONY docker-compose-yorkie-down:
docker-compose -f ./docker/docker-compose-yorkie.yml down
26 changes: 26 additions & 0 deletions build/charts/yorkie-cluster/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

# Istio Operator
istio-operator.yaml
22 changes: 22 additions & 0 deletions build/charts/yorkie-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v2
name: yorkie-cluster
description: yorkie-cluster provides cluster mode for Yorkie server to handle large amount of workloads with ensuring high availability, reliability, and scalability.
type: application
icon: https://raw.githubusercontent.com/yorkie-team/yorkie-team.github.io/main/public/favicon-512x512.png
maintainers:
- name: hackerwins
email: [email protected]
- name: krapie
email: [email protected]

sources:
- https://github.com/yorkie-team/yorkie
version: 0.4.14
appVersion: "0.4.14"
kubeVersion: ">=1.24.0-0"

keywords:
- yorkie
- cluster
- kubernetes
- plumber
59 changes: 59 additions & 0 deletions build/charts/yorkie-cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# yorkie-cluster

Installs the yorkie-cluster, which provides cluster mode for Yorkie server to handle large amount of workloads with ensuring high availability, reliability, and scalability.

## Prerequisites

- Kubernetes 1.24+
- Helm 3+

## Get Helm Repository Info

```bash
helm repo add yorkie-team https://yorkie-team.github.io/yorkie/helm-charts
helm repo update
```

_See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._

## Install Helm Chart

```bash
# Install yorkie cluster helm chart
helm install [RELEASE_NAME] yorkie-team/yorkie-cluster
```

_See [configuration](#configuration) below for custom installation_

_See [`helm install`](https://helm.sh/docs/helm/helm_install/) for command documentation._

## Uninstall Helm Chart

```bash
helm uninstall [RELEASE_NAME]
```

This removes all the Kubernetes components associated with the chart and deletes the release.

_See [`helm uninstall`](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._

## Upgrading Chart

```bash
helm upgrade [RELEASE_NAME] yorkie-team/yorkie-cluster
```

With Helm v3, CRDs created by this chart are not updated by default and should be manually updated.
Consult also the [Helm Documentation on CRDs](https://helm.sh/docs/chart_best_practices/custom_resource_definitions).

_See [`helm upgrade`](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._

## Configuration

See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments:

```console
helm show values yorkie-team/yorkie-cluster
```

You may also `helm show values` on this chart's [dependencies](#dependencies) for additional options.
23 changes: 23 additions & 0 deletions build/charts/yorkie-cluster/charts/mongodb/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions build/charts/yorkie-cluster/charts/mongodb/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: mongodb
description: A mongodb Helm chart dependency for yorkie-cluster

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# 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: "1.16.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: mongodb
26 changes: 26 additions & 0 deletions build/charts/yorkie-cluster/charts/mongodb/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{ if .Values.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: mongodb
namespace: mongodb
labels:
app.kubernetes.io/name: mongodb
app.kubernetes.io/instance: mongodb
app.kubernetes.io/component: database
app.kubernetes.io/part-of: yorkie
app.kubernetes.io/managed-by: helm
spec:
type: ClusterIP
ports:
- name: mongodb
port: {{ .Values.port }}
targetPort: {{ .Values.port }}
protocol: TCP
# TODO(hackerwins): Find an image for ARM64
# - name: mongodb-exporter
# port: 9216
# targetPort: 9216
selector:
app.kubernetes.io/instance: mongodb
{{ end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{ if .Values.enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongodb
namespace: mongodb
labels:
app.kubernetes.io/name: mongodb
app.kubernetes.io/instance: mongodb
app.kubernetes.io/component: database
app.kubernetes.io/part-of: yorkie
app.kubernetes.io/managed-by: helm
spec:
serviceName: mongodb
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: mongodb
template:
metadata:
labels:
app.kubernetes.io/instance: mongodb
spec:
restartPolicy: Always
terminationGracePeriodSeconds: 60
containers:
- name: mongodb
image: mongo:4.4.1
ports:
- containerPort: {{ .Values.port }}
volumeMounts:
- name: mongodb-storage
mountPath: /data/db
# resources will be configured in later updates
# (need to load test to configure resource capacity)
resources: {}
volumeClaimTemplates:
- metadata:
name: mongodb-storage
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: {{ .Values.storageClassName }}
resources:
requests:
storage: {{ .Values.storageSize }}
{{ end }}
9 changes: 9 additions & 0 deletions build/charts/yorkie-cluster/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- Install Complete ---
{{ .Release.Name }} successfully installed!

For next steps, follow:
$ curl https://github.com/yorkie-team/yorkie/tree/main/charts/yorkie-cluster

To learn more about the release, try:
$ helm status {{ .Release.Name }}
$ helm get all {{ .Release.Name }}
39 changes: 39 additions & 0 deletions build/charts/yorkie-cluster/templates/plumber/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.yorkie.name }}-plumber
namespace: {{ .Values.plumber.namespace }}
labels:
app: plumber
app.kubernetes.io/name: plumber
app.kubernetes.io/instance: plumber
app.kubernetes.io/component: server
app.kubernetes.io/part-of: plumber
app.kubernetes.io/managed-by: helm
spec:
{{ if not .Values.yorkie.autoscaling.enabled }}
replicas: 1
{{ end }}
revisionHistoryLimit: 3
selector:
matchLabels:
app.kubernetes.io/instance: plumber
template:
metadata:
labels:
app: plumber
app.kubernetes.io/instance: plumber
spec:
containers:
- name: plumber
image: "{{ .Values.plumber.image.repository }}:{{ .Values.plumber.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.plumber.image.pullPolicy }}
args: [
"--service-discovery",
"kubernetes",
"--target-backend-image",
"yorkieteam/yorkie",
]
ports:
- containerPort: 80
resources: {}
34 changes: 34 additions & 0 deletions build/charts/yorkie-cluster/templates/plumber/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Values.yorkie.name }}
namespace: {{ .Values.plumber.namespace }}
{{ if .Values.ingress.alb.enabled }}
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
# Set alb.ingress.kubernetes.io/certificate-arn annotation to TLS certificate's ARN issued in AWS ACM
alb.ingress.kubernetes.io/certificate-arn: {{ .Values.ingress.alb.certArn }}
alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS": 443}]'
alb.ingress.kubernetes.io/backend-protocol: HTTP
alb.ingress.kubernetes.io/backend-protocol-version: HTTP2
alb.ingress.kubernetes.io/group.name: {{ .Values.ingress.hosts.apiHost }}
alb.ingress.kubernetes.io/group.order: '10'
{{ end }}
spec:
ingressClassName: {{ .Values.ingress.ingressClassName }}
rules:
{{ if .Values.ingress.hosts.enabled }}
- host: {{ .Values.ingress.hosts.apiHost }}
http:
{{ end }}
{{ if not .Values.ingress.hosts.enabled }}
- http:
{{ end }}
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ .Values.yorkie.name }}-plumber
port:
number: 80
4 changes: 4 additions & 0 deletions build/charts/yorkie-cluster/templates/plumber/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: plumber
19 changes: 19 additions & 0 deletions build/charts/yorkie-cluster/templates/plumber/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.yorkie.name }}-plumber
namespace: {{ .Values.yorkie.namespace }}
labels:
app.kubernetes.io/name: plumber
app.kubernetes.io/instance: plumber
app.kubernetes.io/component: loadbalancer
app.kubernetes.io/part-of: plumber
app.kubernetes.io/managed-by: helm
spec:
ports:
- name: {{ .Values.yorkie.name }}-plumber
port: 80
targetPort: 80
protocol: TCP
selector:
app.kubernetes.io/instance: plumber
Loading

0 comments on commit 288ca1d

Please sign in to comment.