Skip to content

Commit

Permalink
Merge pull request #12 from ondat/add_etcd
Browse files Browse the repository at this point in the history
Add etcd helm chart
  • Loading branch information
cvlc authored May 26, 2022
2 parents b8ad1cc + de33393 commit 40e50f2
Show file tree
Hide file tree
Showing 22 changed files with 2,868 additions and 3 deletions.
22 changes: 22 additions & 0 deletions charts/etcd-cluster-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v2
appVersion: "v0.3.3"
description: Cloud Native etcd clusters
name: etcd-cluster-operator
version: 0.0.1
keywords:
- etcd
- kv
- operator
home: https://ondat.io
icon: https://docs.ondat.io/images/generic/Ondat_logo.svg
sources:
- https://github.com/ondat
maintainers:
- name: cvlc
email: [email protected]
- name: DavidMarchant
email: [email protected]
- name: mhmxs
email: [email protected]
- name: aeroniero33
email: [email protected]
21 changes: 21 additions & 0 deletions charts/etcd-cluster-operator/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 StorageOS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
42 changes: 42 additions & 0 deletions charts/etcd-cluster-operator/MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Maintaining the Chart
This chart is mainly the contents of the latest release of the [etcd-cluster-operator](https://github.com/storageos/etcd-cluster-operator/releases) translated to Helm format.

Updating the chart for a new release begins by clearing out the old release:

```shell
rm crds/*.yml
rm templates/*.yml
```

Following that, we should obtain the new version and decompile it into the format expected by Helm:

```shell
OPERATOR_VERSION=v0.3.2
curl -Lo storageos-etcd-cluster-operator.yaml https://github.com/storageos/etcd-cluster-operator/releases/download/$OPERATOR_VERSION/storageos-etcd-cluster-operator.yaml
curl -Lo storageos-etcd-cluster.yaml https://github.com/storageos/etcd-cluster-operator/releases/download/$OPERATOR_VERSION/storageos-etcd-cluster.yaml
yq ea 'select(.kind=="CustomResourceDefinition")' storageos-etcd-cluster-operator.yaml --split-exp='"crds/" + (.metadata.name)'
yq ea 'select(.kind != "CustomResourceDefinition")' storageos-etcd-cluster-operator.yaml --split-exp='"templates/" + (.kind) + "-" + (.metadata.name)'
cat <<EOF > templates/Namespace-storageos-etcd.yml
{{- if .Values.cluster.create -}}
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.cluster.namespace }}
{{- end -}}
EOF
```

The next step will then template various values in the `templates` directory to fit helm's configuration format:

```shell
sed -i templates/* -e 's/namespace: storageos-etcd/namespace: {{ .Release.Namespace }}/g' -e 's/storageos-etcd.svc/{{ .Release.Namespace }}.svc/g'
sed -i templates/Namespace-storageos-etcd.yml -e 's/name: storageos-etcd/name: {{ .Release.Namespace }}/g'
sed -i templates/* -e 's/storageos-etcd/{{ .Release.Name }}/g'
sed -i templates/*.yml -e '0,/labels:/{/labels:/d;}' -e '0,/metadata:/{s/metadata:/metadata:\n{{- template "etcd-cluster-operator.labels" . }}/}'
```

Be sure to update `appVersion` in `Chart.yaml` to the new version used of the operator.

When this is complete, we should rewrite `templates/etcdcluster_cr.yaml` with any changes. This one file is heavily templated for Helm to provide configurability and is correspondent to the file `storageos-etcd-cluster.yaml` from the above mentioned repository.

Before you commit, be sure to check the output of `git diff` and `helm template .` and ensure that the changes make sense.
62 changes: 62 additions & 0 deletions charts/etcd-cluster-operator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# etcd-cluster-operator Helm Chart

Etcd Cluster Operator is an [Operator](https://kubernetes.io/docs/concepts/extend-kubernetes/operator) for automating
the creation and management of etcd inside of Kubernetes. It provides a
[custom resource definition (CRD)](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources)
based API to define etcd clusters with Kubernetes resources, and enable management with native Kubernetes tooling.

## Prerequisites

- Helm 3
- Kubernetes 1.18+

## Installing the chart

```console
# Add ondat charts repo.
$ helm repo add ondat https://ondat.github.io/charts
# Install the chart in a namespace.
$ kubectl create namespace etcd-operator
$ helm install storageos-etcd ondat/etcd-cluster-operator \
--namespace etcd-operator
```

This will install the Etcd cluster operator in `etcd-cluster-operator`
namespace and deploys Etcd with a minimal configuration.

```console
$ helm install ondat/etcd-cluster-operator \
--namespace etcd-operator \
--values <values-file>
```
> **Tip**: List all releases using `helm list -A`
## Configuration

The following tables lists the configurable parameters of the
Operator chart and their default values.

Parameter | Description | Default
--------- | ----------- | -------
`cluster.create` | If true, auto-create the Etcd cluster | `true`

## Deleting an Etcd Cluster

Deleting the `EtcdCluster` custom resource object would delete the
etcd cluster and its associated resources.

In the above example,

```console
$ kubectl delete etcdcluster storageos-etcd --namespace storageos-etcd
```

would delete the custom resource and the cluster.

## Uninstalling the Chart

To uninstall/delete the etcd cluster operator deployment:

```console
$ helm uninstall <release-name> --namespace etcd-operator
```
45 changes: 45 additions & 0 deletions charts/etcd-cluster-operator/ci/std-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Default values for storageos.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

name: etcd-cluster-operator

cluster:
# Whether to create the etcd cluster resource
create: true
# Name of the etcd cluster
name: storageos-etcd
# Namespace to which to deploy the etcd cluster
namespace: storageos-etcd
# Number of replicas for etcd, suggest 3
replicas: 3
# Version of etcd to deploy
version: 3.5.3
# Whether to enable TLS for etcd (recommended)
tls: true
# Storageclass for etcd backing storage
storageclass: standard
# Amount of storage to allocate per etcd volume
storage: 1Gi
# Resource requests and limits for etcd pods
resources:
requests:
cpu: 200m
memory: 200Mi
limits:
cpu: 200m
memory: 200Mi
# Node selector terms to install etcd on
nodeSelectorTerm:
key:
value:
# Pod toleration for etcd pods
toleration:
key:
value:

ondat:
# Namespace in which ondat operator is installed
namespace: storageos
# etcd secret for ondat operator within above namespace
secret: storageos-etcd-secret
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: etcdbackups.etcd.improbable.io
spec:
group: etcd.improbable.io
names:
kind: EtcdBackup
listKind: EtcdBackupList
plural: etcdbackups
singular: etcdbackup
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: EtcdBackup is the Schema for the etcdbackups API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: EtcdBackupSpec defines the desired state of EtcdBackup
properties:
destination:
description: Destination is the remote location where the backup will be placed.
properties:
objectURLTemplate:
description: "ObjectURLTemplate is a URL of a file of a backup in object storage. \n It *MAY* contain go-template style template fields. The fields *MUST* match fields the EtcdBackup resource. For example: s3://example-bucket/snapshot.db s3://example-bucket/{{ .Namespace }}/{{ .Name }}/{{ .CreationTimestamp }}/snapshot.db \n You *SHOULD* include template fields if the URL will be used in an EtcdBackupSchedule, to ensure that every backup has a unique name. For example: s3://example-bucket/snapshot-{{ .UID }}.db \n The scheme of this URL should be gs:// or s3://."
type: string
required:
- objectURLTemplate
type: object
source:
description: Source describes the cluster to be backed up.
properties:
clusterURL:
description: ClusterURL is a URL endpoint for a single Etcd server. The etcd-cluster-operator backup-agent connects to this endpoint, downloads a snapshot from remote etcd server and uploads the data to EtcdBackup.Destination.ObjectURLTemplate. The Etcd Snapshot API works with a single selected node, and the saved snapshot is the point-in-time state of that selected node. See https://github.com/etcd-io/etcd/blob/v3.4.4/clientv3/snapshot/v3_snapshot.go#L53
type: string
required:
- clusterURL
type: object
required:
- destination
- source
type: object
status:
description: EtcdBackupStatus defines the observed state of EtcdBackup
properties:
completionTime:
description: CompletionTime is the time that this backup entered the `Completed' phase.
format: date-time
type: string
phase:
description: Phase defines the current operation that the backup process is taking.
type: string
startTime:
description: StartTime is the times that this backup entered the `BackingUp' phase.
format: date-time
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: etcdbackupschedules.etcd.improbable.io
spec:
group: etcd.improbable.io
names:
kind: EtcdBackupSchedule
listKind: EtcdBackupScheduleList
plural: etcdbackupschedules
singular: etcdbackupschedule
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: EtcdBackupSchedule is the Schema for the etcdbackupschedules API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: EtcdBackupScheduleSpec defines the desired state of EtcdBackupSchedule
properties:
backupTemplate:
description: BackupTemplate describes the template used to create backup resources. Every time the schedule fires an `EtcdBackup' will be created with this template.
properties:
destination:
description: Destination is the remote location where the backup will be placed.
properties:
objectURLTemplate:
description: "ObjectURLTemplate is a URL of a file of a backup in object storage. \n It *MAY* contain go-template style template fields. The fields *MUST* match fields the EtcdBackup resource. For example: s3://example-bucket/snapshot.db s3://example-bucket/{{ .Namespace }}/{{ .Name }}/{{ .CreationTimestamp }}/snapshot.db \n You *SHOULD* include template fields if the URL will be used in an EtcdBackupSchedule, to ensure that every backup has a unique name. For example: s3://example-bucket/snapshot-{{ .UID }}.db \n The scheme of this URL should be gs:// or s3://."
type: string
required:
- objectURLTemplate
type: object
source:
description: Source describes the cluster to be backed up.
properties:
clusterURL:
description: ClusterURL is a URL endpoint for a single Etcd server. The etcd-cluster-operator backup-agent connects to this endpoint, downloads a snapshot from remote etcd server and uploads the data to EtcdBackup.Destination.ObjectURLTemplate. The Etcd Snapshot API works with a single selected node, and the saved snapshot is the point-in-time state of that selected node. See https://github.com/etcd-io/etcd/blob/v3.4.4/clientv3/snapshot/v3_snapshot.go#L53
type: string
required:
- clusterURL
type: object
required:
- destination
- source
type: object
schedule:
description: Schedule holds a crontab-like scheule holding defining the schedule in which backups will be started.
type: string
required:
- backupTemplate
- schedule
type: object
status:
description: EtcdBackupScheduleStatus defines the observed state of EtcdBackupSchedule
type: object
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading

0 comments on commit 40e50f2

Please sign in to comment.