Skip to content

Commit

Permalink
Initial code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
swoehrl-mw committed Apr 27, 2022
1 parent 494d7c9 commit fab9ceb
Show file tree
Hide file tree
Showing 30 changed files with 1,424 additions and 1 deletion.
53 changes: 53 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Create new release
on:
push:
tags:
- 'v*'
jobs:
release:
name: Create new release
runs-on: ubuntu-latest
steps:

- name: Check out the repo
uses: actions/checkout@v2

- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image to GitHub Container Registry
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/hybrid-cloud-object-storage-operator
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
TAG=${GITHUB_REF//refs\/tags\/v}
docker build . -t $IMAGE_ID:$TAG
docker push $IMAGE_ID:$TAG
- name: Prepare helm chart
env:
GITHUB_REF: ${{ github.ref }}
run: |
VERSION=${GITHUB_REF//refs\/tags\/v}
sed -i 's/0.0.1/'"${VERSION}"'/' helm/hybrid-cloud-object-storage-operator/Chart.yaml
sed -i 's/dev/'"${VERSION}"'/' helm/hybrid-cloud-object-storage-operator/values.yaml
- name: Publish helm chart
uses: stefanprodan/helm-gh-pages@master
with:
charts_dir: helm
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode
.pyc
__pycache__
/charts
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.10-slim

RUN mkdir /operator
WORKDIR /operator
# Install python dependencies
COPY requirements.txt /operator/requirements.txt
RUN pip install -r /operator/requirements.txt && rm -rf /root/.cache/pip
# Copy operator code
COPY main.py /operator/
COPY hybridcloud /operator/hybridcloud
CMD ["kopf", "run", "--liveness=http://0.0.0.0:8080/healthz", "main.py", "-A"]
219 changes: 218 additions & 1 deletion README.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions examples/azureblob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: hybridcloud.maibornwolff.de/v1alpha1
kind: ObjectStorageBucket
metadata:
name: demoteam
namespace: default
spec:
interface: azureblob
network:
publicAccess: false
containers:
- name: demo
anonymousAccess: false
credentialsSecret: demoteam-storage-credentials
23 changes: 23 additions & 0 deletions helm/hybrid-cloud-object-storage-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/
6 changes: 6 additions & 0 deletions helm/hybrid-cloud-object-storage-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: hybrid-cloud-object-storage-operator
description: A Helm chart for Kubernetes
type: application
version: 0.0.1
appVersion: "0.1.0"
116 changes: 116 additions & 0 deletions helm/hybrid-cloud-object-storage-operator/crds/objectstorage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: objectstoragebuckets.hybridcloud.maibornwolff.de
spec:
scope: Namespaced
group: hybridcloud.maibornwolff.de
names:
kind: ObjectStorageBucket
plural: objectstoragebuckets
singular: objectstoragebucket
shortNames:
- bucket
versions:
- name: v1alpha1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
backend:
type: string
interface:
type: string
credentialsSecret:
type: string
network:
type: object
properties:
publicAccess:
type: boolean
firewallRules:
type: array
items:
type: object
properties:
name:
type: string
cidr:
type: string
required:
- name
- cidr
security:
type: object
properties:
anonymousAccess:
type: boolean
cors:
type: array
items:
type: object
properties:
name:
type: string
allowedOrigins:
type: array
items:
type: string
allowedMethods:
type: array
items:
type: string
exposedHeaders:
type: array
items:
type: string
allowedHeaders:
type: array
items:
type: string
maxAgeInSeconds:
type: number
required:
- name
- allowedOrigins
- allowedMethods
- exposedHeaders
- allowedHeaders
- maxAgeInSeconds
dataRetention:
type: object
properties:
versioning:
type: object
properties:
enabled:
type: boolean
deleteRetention:
type: object
properties:
enabled:
type: boolean
retentionPeriodInDays:
type: number
containers:
type: array
items:
type: object
properties:
name:
type: string
anonymousAccess:
type: boolean
required:
- name
required:
- credentialsSecret
status:
type: object
x-kubernetes-preserve-unknown-fields: true
nullable: true
69 changes: 69 additions & 0 deletions helm/hybrid-cloud-object-storage-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "operator.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "operator.labels" -}}
helm.sh/chart: {{ include "operator.chart" . }}
{{ include "operator.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "operator.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "operator.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the configmap for the operator config
*/}}
{{- define "operator.configname" -}}
{{ printf "%s-config" (include "operator.fullname" . | trunc 56) }}
{{- end }}
11 changes: 11 additions & 0 deletions helm/hybrid-cloud-object-storage-operator/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.operatorConfig }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "operator.configname" . }}
labels:
{{- include "operator.labels" . | nindent 4 }}
data:
config.yaml: |
{{ required "operatorConfig is required" .Values.operatorConfig | nindent 4 }}
{{- end }}
Loading

0 comments on commit fab9ceb

Please sign in to comment.