Init commit

This commit is contained in:
Nikolai Rodionov 2024-04-02 17:21:21 +02:00
commit 30451e2b5f
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD
7 changed files with 133 additions and 0 deletions

32
.woodpecker/build.yaml Normal file
View File

@ -0,0 +1,32 @@
---
when:
event:
- push
steps:
build:
image: git.badhouseplants.net/badhouseplants/badhouseplants-builder:152f5b777abda1b18e3b231c295e2574f0e1cbdb
name: Build shoebill operator image
privileged: true
environment:
- PACKAGE_NAME=softplayer/softplayer-backend
commands:
- git config --global --add safe.directory '*'
- |
if [[ "${CI_COMMIT_TAG}" ]]; then
export CUSTOM_TAG="${CI_COMMIT_TAG}";
fi
- build-container
secrets:
- gitea_token
backend_options:
kubernetes:
resources:
requests:
memory: 500Mi
cpu: 200m
limits:
memory: 1000Mi
cpu: 1000m
securityContext:
privileged: true

3
Containerfile Normal file
View File

@ -0,0 +1,3 @@
FROM ghcr.io/flant/shell-operator:latest
ADD /hooks /hooks
ADD /tpls /tpls

9
examples/cm.yaml Normal file
View File

@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: test
labels:
component: bootstrap
data:
provider: hetzner
cluster: k3s

11
examples/pod.yaml Normal file
View File

@ -0,0 +1,11 @@
apiVersion: v1
kind: Pod
metadata:
name: shell-operator
spec:
containers:
- name: shell-operator
image: so
imagePullPolicy: Never
serviceAccountName: monitor-pods-cm

15
hooks/down.sh Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
if [[ $1 == "--config" ]] ; then
cat <<EOF
configVersion: v1
kubernetes:
- apiVersion: v1
kind: Pod
executeHookOnEvent: ["Added"]
EOF
else
podName=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH)
echo "Pod '${podName}' added"
fi

35
hooks/up.sh Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env bash
# ---------------------------------------------------------------------
# This script should bootstrap a new environment, or update
# existing ones
# Get the configmap name and namespace to prepare the
# ---------------------------------------------------------------------
if [[ $1 == "--config" ]] ; then
cat <<EOF
configVersion: v1
kubernetes:
- name: Watch softplayer configmaps
apiVersion: v1
kind: ConfigMap
executeHookOnEvent: ["Added"]
labelSelector:
matchExpressions:
- key: "component"
operator: "In"
values: ["bootstrap"]
EOF
else
cmName=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH)
echo "ConfigMap '${cmName}' added"
PROVIDER=$(jq -r .[0].object.data.provider $BINDING_CONTEXT_PATH)
KUBERNETES=$(jq -r .[0].object.data.kubernetes $BINDING_CONTEXT_PATH)
if ! [ -f /tpls/${PROVIDER}-${KUBERNETES}.yaml ]; then
echo "ERROR: template not found for ${PROVIDER}-${KUBERNETES}"
exit 1
fi
export SP_CUSTOMER_ID=$(jq -r .[0].object.metadata.namespace $BINDING_CONTEXT_PATH)
export SP_ENVIRONMENT=$(jq -r .[0].object.metadata.name $BINDING_CONTEXT_PATH)
envsubst < /tpls/${PROVIDER}-${KUBERNETES}.yaml | kubectl create -f -
fi

28
tpls/hetzner-k8s.yaml Normal file
View File

@ -0,0 +1,28 @@
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: hetzner-k3s
namespace: "${SP_TEKTON_RUNTIME_NS}"
spec:
params:
- name: namespace
value: "${SP_CUSTOMER_ID}"
- name: environment
value: "${SP_ENVIRONMENT}"
pipelineRef:
resolver: cluster
params:
- name: kind
value: pipeline
- name: name
value: hetzner-k3s
- name: namespace
value: tekton-pipelines
workspaces:
- name: ssh-keys
emptyDir: {}
- name: inventory
emptyDir: {}
- name: kubeconfig-output
emptyDir: {}
serviceAccountName: secret-manager