Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/didil/autobucket-operator
Cloud Storage Kubernetes Operator with Go and Operator SDK
https://github.com/didil/autobucket-operator
cloud golang kubernetes kubernetes-operator
Last synced: 3 months ago
JSON representation
Cloud Storage Kubernetes Operator with Go and Operator SDK
- Host: GitHub
- URL: https://github.com/didil/autobucket-operator
- Owner: didil
- License: mit
- Created: 2020-11-17T17:54:02.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-20T11:26:02.000Z (almost 4 years ago)
- Last Synced: 2024-05-22T13:32:12.174Z (6 months ago)
- Topics: cloud, golang, kubernetes, kubernetes-operator
- Language: Go
- Homepage:
- Size: 70.3 KB
- Stars: 12
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Autobucket Operator
Kubernetes Operator that automatically creates and manages Cloud Buckets (Object Storage) for k8s Deployments. Built with Go and Operator SDK.[![Build Status](https://travis-ci.org/didil/autobucket-operator.svg?branch=master)](https://travis-ci.org/didil/autobucket-operator)
This repository is a companion repo for the article: [Autobucket Operator: Building a Cloud Storage Kubernetes Operator with Go and Operator SDK](https://didil.medium.com/autobucket-operator-7e77eca95fcc)
**THIS SOFTWARE IS WORK IN PROGRESS / ALPHA RELEASE AND IS NOT MEANT FOR USAGE IN PRODUCTION SYSTEMS**
## Tests
To run tests:
````
$ make test
````## Run locally
````
# install the k8s resources
$ make install
# run the operator locally
$ make run
````## Deploy (GCP example)
Authenticate to GCP
```
gcloud auth login
```
Create a new gcp project (choose a unique GCP_PROJECT)
```
gcloud projects create $GCP_PROJECT
```
Create a service account for the operator
```
SERVICE_ACCOUNT=autobucket-operator
gcloud iam service-accounts create $SERVICE_ACCOUNT \
--project $GCP_PROJECT
```
Grant Storage Admin role to the service account
```
gcloud projects add-iam-policy-binding $GCP_PROJECT \
--member=serviceAccount:$SERVICE_ACCOUNT@$GCP_PROJECT.iam.gserviceaccount.com \
--role=roles/storage.admin \
--project $GCP_PROJECT
```
Create Service Account keys
```
gcloud iam service-accounts keys create sa-operator.json \
--iam-account $SERVICE_ACCOUNT@$GCP_PROJECT.iam.gserviceaccount.com \
--project $GCP_PROJECT
```*Make sure you KUBECONFIG is set before continuing, the deployment will use your current context*
Create a Kubernetes secret for the service account credentials
````
kubectl create secret generic autobucket-gcp-credentials --from-file=sa-operator.json=sa-operator.json -n autobucket-operator-system
````Deploy resources and controller manager
````
# install the k8s resources
$ make install
# deploy the controller manager
$ GCP_PROJECT=$GCP_PROJECT make deploy
````## Usage
Deployment annotations sample:
````
apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-deployment
annotations:
ab.leclouddev.com/cloud: gcp
ab.leclouddev.com/name-prefix: ab
ab.leclouddev.com/on-delete-policy: destroy
````- ````ab.leclouddev.com/cloud````: cloud where the storage bucket is created. Valid options: "gcp". If this annotation is missing or empty, no bucket is created for the deployment.
- ````ab.leclouddev.com/name-prefix````: storage bucket name prefix. Default: "ab" (short name for autobucket).
- ````ab.leclouddev.com/on-delete-policy````: bucket deletion policy when the deployment is deleted. Valid options: "ignore" (do nothing), "destroy" (delete the storage bucket).
The full name format for the created storage buckets is "{prefix}-{namespace}-{deployment-name}"For example, the previous deployment, when deployed to the default namespace will automatically create a GCP Bucket: "ab-default-sample-deployment"
## TODO
- [ ] Add AWS S3 Support
- [ ] Additional Bucket configuration options
- [ ] Helm chart for simpler deployment