Skip to content

Commit

Permalink
Merge branch 'Opster:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhvigodithi authored Jun 12, 2022
2 parents 30a90ff + 824c88a commit 4e82477
Show file tree
Hide file tree
Showing 18 changed files with 399 additions and 97 deletions.
57 changes: 2 additions & 55 deletions charts/opensearch-operator/README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,11 @@
![build](https://github.com/opster/opensearch-k8s-operator/actions/workflows/docker-build.yaml/badge.svg) ![test](https://github.com/opster/opensearch-k8s-operator/actions/workflows/testing.yaml/badge.svg) ![release](https://img.shields.io/github/v/release/opster/opensearch-k8s-operator)

# OpenSearch-k8s-operator

The Kubernetes OpenSearch Operator is used for automating the deployment, provisioning, management, and orchestration of OpenSearch clusters and OpenSearch dashboards.
The Kubernetes [OpenSearch Operator](https://github.com/Opster/opensearch-k8s-operator) is used for automating the deployment, provisioning, management, and orchestration of OpenSearch clusters and OpenSearch dashboards.

## Getting started

The Operator can be easily installed using helm on any CNCF-certified Kubernetes cluster. Please refer to the [User Guide](./docs/userguide/main.md) for installation instructions.

## Roadmap

The full roadmap is available in the [Development plan](./docs/designs/dev-plan.md).

Currently planned features:

- [x] Deploy a new OS cluster.
- [x] Ability to deploy multiple clusters.
- [x] Spin up OS dashboards.
- [x] Configuration of all node roles (master, data, coordinating..).
- [x] Scale the cluster resources (manually), per nodes' role group.
- [x] Drain strategy for scale down.
- [x] Version updates.
- [x] Change nodes' memory allocation and limits.
- [x] Secured installation features.
- [x] Certificate management.
- [x] Rolling restarts - through API.
- [x] Scaling nodes' disks - increase disk size.
- [ ] Cluster configurations and nodes' settings updates.
- [ ] Auto scaler based on usage, load, and resources.
- [ ] Operator Monitoring, with Prometheus and Grafana.
- [ ] Control shard balancing and allocation: AZ/Rack awareness, Hot/Warm.

## Development

### Running the Operator locally

- Clone the repo and go to the `opensearch-operator` folder.
- Run `make build manifests` to build the controller binary and the manifests
- Start a Kubernetes cluster (e.g. with k3d or minikube) and make sure your `~/.kube/config` points to it
- Run `make install` to create the CRD in the kubernetes cluster
- Start the Operator by running `make run`
The Operator can be easily installed using helm on any CNCF-certified Kubernetes cluster. Please refer to the [User Guide](https://github.com/Opster/opensearch-k8s-operator/blob/main/docs/userguide/main.md) for more information.

**Note: use GO 1.17 version**

Now you can deploy an Opensearch cluster.

Go to `opensearch-operator` and use `opensearch-cluster.yaml` as a starting point to define your cluster. Then run:

```bash
kubectl apply -f opensearch-cluster.yaml
```

In order to delete the cluster, you just delete your OpenSearch cluster resource. This will delete the cluster and all of its resources.

```bash
kubectl delete -f opensearch-cluster.yaml
```
### Installation Using Helm

#### Get Repo Info
Expand All @@ -80,6 +30,3 @@ helm upgrade [RELEASE_NAME] opensearch-operator/opensearch-operator

[![Watch the video](https://opster.com/wp-content/uploads/2022/05/Operator-Installation-Tutorial.png)](https://player.vimeo.com/video/708641527)

## Contributions

We welcome contributions! See how you can get involved by reading [CONTRIBUTING.md](./CONTRIBUTING.md).
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ spec:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
{{- if .Values.manager.watchNamespace }}
- --watch-namespace={{ .Values.manager.watchNamespace }}
{{- end }}
command:
- /manager
image: "{{ .Values.manager.image.repository }}:{{ .Values.manager.image.tag }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ spec:
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
image:
type: string
imagePullPolicy:
description: PullPolicy describes a policy for if/when to pull
a container image
type: string
imagePullSecrets:
items:
description: LocalObjectReference contains enough information
to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
type: array
replicas:
format: int32
type: integer
Expand Down
3 changes: 3 additions & 0 deletions charts/opensearch-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ manager:
image:
repository: public.ecr.aws/opsterio/opensearch-operator
tag: latest
# If a watchNamespace is specified, the manager's cache will be restricted to
# watch objects in the desired namespace. Defaults is to watch all namespaces.
watchNamespace:
28 changes: 28 additions & 0 deletions docs/designs/crd.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,34 @@ Dashboards defines Opensearch-Dashboard configuration and deployment
<td>false</td>
<td>false</td>
</tr><tr>
</tr><tr>
<td><b>env</b></td>
<td>[]corev1.Env</td>
<td>add user defined environment variables to dashboard app</td>
<td>false</td>
<td> - </td>
</tr><tr>
</tr><tr>
<td><b>image</b></td>
<td>string</td>
<td>Define Opensearch-dashboards image</td>
<td>false</td>
<td> - </td>
</tr><tr>
</tr><tr>
<td><b>imagePullPolicy</b></td>
<td>corev1.PullPolicy</td>
<td>Define Opensearch-dashboards image pull policy</td>
<td>false</td>
<td> - </td>
</tr><tr>
</tr><tr>
<td><b>imagePullSecrets</b></td>
<td>corev1.LocalObjectReference</td>
<td>Define Opensearch-dashboards image pull secrets</td>
<td>false</td>
<td> - </td>
</tr><tr>
</table>


Expand Down
9 changes: 5 additions & 4 deletions docs/userguide/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This guide is intended for users of the Opensearch Operator. If you want to cont

The Operator can be easily installed using Helm:

1. Add the helm repo: `helm repo add opensearch-operator https://opster.github.io/opensearch-k8s-operator-chart/`
1. Add the helm repo: `helm repo add opensearch-operator https://opster.github.io/opensearch-k8s-operator/`
2. Install the Operator: `helm install opensearch-operator opensearch-operator/opensearch-operator`

Follow the instructions in this video to install the Operator:
Expand Down Expand Up @@ -88,9 +88,10 @@ nodePools:
- "data"
- "master"
persistence:
storageClass: mystorageclass
accessModes:
- ReadWriteOnce
pvc:
storageClass: mystorageclass
accessModes:
- ReadWriteOnce
```
or
Expand Down
12 changes: 7 additions & 5 deletions opensearch-operator/api/v1/opensearch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ type ConfMgmt struct {
}

type DashboardsConfig struct {
Enable bool `json:"enable,omitempty"`
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
Replicas int32 `json:"replicas"`
Tls *DashboardsTlsConfig `json:"tls,omitempty"`
Version string `json:"version"`
Enable bool `json:"enable,omitempty"`
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
Replicas int32 `json:"replicas"`
Tls *DashboardsTlsConfig `json:"tls,omitempty"`
Version string `json:"version"`
*ImageSpec `json:",omitempty"`
// Additional properties for opensearch_dashboards.yaml
AdditionalConfig map[string]string `json:"additionalConfig,omitempty"`
// Secret that contains fields username and password for dashboards to use to login to opensearch, must only be supplied if a custom securityconfig is provided
OpensearchCredentialsSecret corev1.LocalObjectReference `json:"opensearchCredentialsSecret,omitempty"`
Env []corev1.EnvVar `json:"env,omitempty"`
}

type DashboardsTlsConfig struct {
Expand Down
12 changes: 12 additions & 0 deletions opensearch-operator/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,132 @@ spec:
type: object
enable:
type: boolean
env:
items:
description: EnvVar represents an environment variable present
in a Container.
properties:
name:
description: Name of the environment variable. Must be a
C_IDENTIFIER.
type: string
value:
description: 'Variable references $(VAR_NAME) are expanded
using the previously defined environment variables in
the container and any service environment variables. If
a variable cannot be resolved, the reference in the input
string will be unchanged. Double $$ are reduced to a single
$, which allows for escaping the $(VAR_NAME) syntax: i.e.
"$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)".
Escaped references will never be expanded, regardless
of whether the variable exists or not. Defaults to "".'
type: string
valueFrom:
description: Source for the environment variable's value.
Cannot be used if value is not empty.
properties:
configMapKeyRef:
description: Selects a key of a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the ConfigMap or its
key must be defined
type: boolean
required:
- key
type: object
fieldRef:
description: 'Selects a field of the pod: supports metadata.name,
metadata.namespace, `metadata.labels[''<KEY>'']`,
`metadata.annotations[''<KEY>'']`, spec.nodeName,
spec.serviceAccountName, status.hostIP, status.podIP,
status.podIPs.'
properties:
apiVersion:
description: Version of the schema the FieldPath
is written in terms of, defaults to "v1".
type: string
fieldPath:
description: Path of the field to select in the
specified API version.
type: string
required:
- fieldPath
type: object
resourceFieldRef:
description: 'Selects a resource of the container: only
resources limits and requests (limits.cpu, limits.memory,
limits.ephemeral-storage, requests.cpu, requests.memory
and requests.ephemeral-storage) are currently supported.'
properties:
containerName:
description: 'Container name: required for volumes,
optional for env vars'
type: string
divisor:
anyOf:
- type: integer
- type: string
description: Specifies the output format of the
exposed resources, defaults to "1"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
resource:
description: 'Required: resource to select'
type: string
required:
- resource
type: object
secretKeyRef:
description: Selects a key of a secret in the pod's
namespace
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
type: object
required:
- name
type: object
type: array
image:
type: string
imagePullPolicy:
description: PullPolicy describes a policy for if/when to pull
a container image
type: string
imagePullSecrets:
items:
description: LocalObjectReference contains enough information
to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?'
type: string
type: object
type: array
opensearchCredentialsSecret:
description: Secret that contains fields username and password
for dashboards to use to login to opensearch, must only be supplied
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ metadata:
namespace: default
spec:
general:
version: 1.3.0
version: 1.3.2
httpPort: 9200
vendor: opensearch
version: latest
serviceName: my-cluster
dashboards:
version: 1.3.0
version: 1.3.2
enable: true
replicas: 2
resources:
Expand Down
3 changes: 1 addition & 2 deletions opensearch-operator/examples/opensearch-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ metadata:
namespace: default
spec:
general:
version: 1.3.0
version: 1.3.2
httpPort: 9200
vendor: opensearch
version: latest
serviceName: my-cluster
dashboards:
version: 1.3.0
Expand Down
Loading

0 comments on commit 4e82477

Please sign in to comment.