Skip to content

Commit

Permalink
nutanix csi 3.0-rc6
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxtof committed Dec 1, 2023
1 parent 70e95ea commit cbddb39
Show file tree
Hide file tree
Showing 53 changed files with 1,804 additions and 948 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Enable version updates for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
7 changes: 7 additions & 0 deletions .github/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# three node (two workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
4 changes: 2 additions & 2 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.2.1
uses: helm/chart-testing-action@v2.4.0

- name: Run chart-testing (lint-changed)
id: list-changed
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -20,6 +20,7 @@ jobs:
git config user.email "[email protected]"
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.3.0
uses: helm/chart-releaser-action@v1.5.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: true
10 changes: 6 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.2.1
uses: helm/chart-testing-action@v2.4.0

- name: Run chart-testing (lint-changed)
id: list-changed
Expand All @@ -26,8 +26,10 @@ jobs:
run: ct lint

- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.2.0
uses: helm/kind-action@v1.5.0
if: steps.list-changed.outputs.changed == 'true'
with:
config: .github/kind-config.yaml

- name: Run chart-testing (install)
run: ct install
run: ct install --helm-extra-set-args "--set=kindtest=true"
23 changes: 23 additions & 0 deletions charts/ndb-operator/.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/
36 changes: 36 additions & 0 deletions charts/ndb-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: v2
name: ndb-operator
description: A Helm chart for Nutanix Database Kubernetes Operator
type: application
version: 0.0.3
appVersion: "v0.0.3"
maintainers:
- name: balakumarbalu
email: [email protected]
- name: krunal-jhaveri
email: [email protected]
- name: manavrajvanshi
email: [email protected]
- name: nutanix-cloud-native-bot
email: [email protected]
icon: https://www.nutanix.com/content/dam/nutanix/global/icons/products/svg/Nutanix-Era-40.svg
annotations:
artifacthub.io/changes: |
- kind: security
description: "Updated kube-proxy version"
- kind: security
description: "Updated multiple golang dependecy version"
artifacthub.io/containsSecurityUpdates: "true"
artifacthub.io/license: Apache-2.0
artifacthub.io/maintainers: |
- name: Balakumar Balu
email: [email protected]
- name: Krunal Jhaveri
email: [email protected]
- name: Manav Rajvanshi
email: [email protected]
- name: Nutanix Cloud Native Team
email: [email protected]
artifacthub.io/operator: "true"
artifacthub.io/operatorCapabilities: Basic Install
artifacthub.io/prerelease: "true"
173 changes: 173 additions & 0 deletions charts/ndb-operator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Nutanix Database Service Operator for Kubernetes
The NDB operator automates and simplifies database administration, provisioning, and life-cycle management of NDB on Kubernetes.

NDB operator supports these functionalities:
1. Provisioning and deprovisioning a single instance postgres database.
2. Creation of a service for the applications to consume the database within Kubernetes.
---

## Pre-requisites
1. [Install](https://portal.nutanix.com/page/documents/details?targetId=Nutanix-NDB-User-Guide-v2_5:top-installation-c.html) NDB 2.5.
2. [Install](https://helm.sh/docs/intro/install/) Helm v3.0.0.
3. [Install](https://kubernetes.io/docs/setup/) a Kubernetes cluster.

## Installation and Running on the cluster
Deploy the operator on the cluster:
```sh
helm repo add nutanix https://nutanix.github.io/helm/

helm install ndb-operator nutanix/ndb-operator -n ndb-operator --create-namespace
```
## Using the Operator

1. Create the secrets that are to be used by the custom resource:
```yaml
apiVersion: v1
kind: Secret
metadata:
name: your-ndb-secret
type: Opaque
stringData:
username: username-for-ndb-server
password: password-for-ndb-server
ca_certificate: |
-----BEGIN CERTIFICATE-----
CA CERTIFICATE (ca_certificate is optional)
-----END CERTIFICATE-----
---
apiVersion: v1
kind: Secret
metadata:
name: your-db-secret
type: Opaque
stringData:
password: password-for-the-database-instance
ssh_public_key: SSH-PUBLIC-KEY

```
2. To create instances of custom resources (provision databases), edit the crd file with the NDB installation and database instance details and run:
```sh
kubectl apply -f CRD_FILE.yaml
```
3. To delete instances of custom resources (deprovision databases) run:
```sh
kubectl delete -f CRD_FILE.yaml
```
The CRD is described as follows:
```yaml
apiVersion: ndb.nutanix.com/v1alpha1
kind: Database
metadata:
# This name that will be used within the kubernetes cluster
name: db
spec:
# NDB server specific details
ndb:
# Cluster id of the cluster where the Database has to be provisioned
# Can be fetched from the GET /clusters endpoint
clusterId: "Nutanix Cluster Id"
# Credentials secret name for NDB installation
# data: username, password,
# stringData: ca_certificate
credentialSecret: your-ndb-secret
# The NDB Server
server: https://[NDB IP]:8443/era/v0.9
# Set to true to skip SSL verification, default: false.
skipCertificateVerification: false
# Database instance specific details (that is to be provisioned)
databaseInstance:
# The database instance name on NDB
databaseInstanceName: "Database-Instance-Name"
# Names of the databases on that instance
databaseNames:
- alpha
- beta
# Credentials secret name for NDB installation
# data: password, ssh_public_key
credentialSecret: your-db-secret
size: 10
timezone: "UTC"
type: postgres
```
## Uninstalling the Chart
To uninstall/delete the operator deployment/chart:
```console
helm uninstall ndb-operator -n ndb-operator
```
---
## Configuration

The following table lists the configurable parameters of the NDB operator chart and their default values.

| Parameter | Description | Default |
|-----------------------|---------------------------------------------------------------|--------------------------------------------------------|
| `replicaCount` | Number of replicas of the NDB Operator controller pods | `1` |
| `image.repository` | Image for NDB Operator controller | `ghcr.io/nutanix-cloud-native/ndb-operator/controller` |
| `image.pullPolicy` | Image pullPolicy | `IfNotPresent` |
| `image.tag` | Image tag | `v0.0.3, defaults to Chart.appVersion if removed` |
| `imagePullSecrets` | ImagePullSecrets list | `[]` |
| `nameOverride` | To override the name of the operator chart | `""` |
| `fullnameOverride` | To override the full name of the operator chart | `""` |
| `serviceAccount.name` | Name of the service account that will be used by the operator | `ndb-operator-service-account` |
| `podAnnotations` | Add annotation to NDB Operator controller pods | `kubectl.kubernetes.io/default-container: manager` |
| `podSecurityContext` | Security context for the pod(s) running the operator | `runAsNonRoot: true` |
| `securityContext` | Security context for the container running the controller | `allowPrivilegeEscalation: false` |
| `resources` | Configure resources for Cloud Provider Pod | `refer to values.yaml` |
| `nodeSelector` | Configure nodeSelector for Cloud Provider Pod | `refer to values.yaml` |
| `tolerations` | Configure tolerations for Cloud Provider Pod | `refer to values.yaml` |
| `affinity` | Configure affinity for Cloud Provider Pod | `refer to values.yaml` |


### Configuration examples:

Install the operator in the `ndb-operator` namespace (add the `--create-namespace` flag if the namespace does not exist):

```console
helm install ndb-operator nutanix/ndb-operator -n ndb-operator
```

Individual configurations can be set by using `--set key=value[,key=value]` like:
```console
helm install ndb-operator nutanix/ndb-operator --set replicaCount=2
```
In the above command `replicaCount` refers to one of the variables defined in the values.yaml file.

All the options can also be specified in a value.yaml file:

```console
helm install ndb-operator nutanix/ndb-operator -f value.yaml
```
---

## How it works

This project aims to follow the Kubernetes [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/)

It uses [Controllers](https://kubernetes.io/docs/concepts/architecture/controller/)
which provides a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster.

A custom resource of the kind Database is created by the reconciler, followed by a Service and an Endpoint that maps to the IP address of the database instance provisioned. Application pods/deployments can use this service to interact with the databases provisioned on NDB through the native Kubernetes service.

Pods can specify an initContainer to wait for the service (and hence the database instance) to get created before they start up.
```yaml
initContainers:
- name: init-db
image: busybox:1.28
command: ['sh', '-c', "until nslookup <<Database CR Name>>-svc.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for database service; sleep 2; done"]
```
## Contributing
See the [contributing docs](https://github.com/nutanix-cloud-native/ndb-operator/blob/main/CONTRIBUTING.md).
## Support
### Community Plus
This code is developed in the open with input from the community through issues and PRs. A Nutanix engineering team serves as the maintainer. Documentation is available in the project repository.
Issues and enhancement requests can be submitted in the [Issues tab of this repository](https://github.com/nutanix-cloud-native/ndb-operator/issues). Please search for and review the existing open issues before submitting a new issue.
## License
Copyright 2021-2022 Nutanix, Inc.
The project is released under version 2.0 of the [Apache license](http://www.apache.org/licenses/LICENSE-2.0).
Loading

0 comments on commit cbddb39

Please sign in to comment.