Skip to content

Instantly share code, notes, and snippets.

View mmontes11's full-sized avatar
🦭
Feeding mariadb-operator

Martin Montes mmontes11

🦭
Feeding mariadb-operator
View GitHub Profile
@mmontes11
mmontes11 / controller.go
Last active July 30, 2021 11:04
Kubernetes controller
type Controller struct {
kubeClientSet kubernetes.Interface
echoInformer cache.SharedIndexInformer
jobInformer cache.SharedIndexInformer
scheduledEchoInformer cache.SharedIndexInformer
cronjobInformer cache.SharedIndexInformer
queue workqueue.RateLimitingInterface
@mmontes11
mmontes11 / k8s-api-conn.go
Last active July 30, 2021 10:18
Connect to Kubernetes API
var restConfig *rest.Config
var errKubeConfig error
if config.KubeConfig != "" {
restConfig, errKubeConfig = clientcmd.BuildConfigFromFlags("", config.KubeConfig)
} else {
restConfig, errKubeConfig = rest.InClusterConfig()
}
if errKubeConfig != nil {
logger.Fatal("error getting kubernetes config ", err)
}
@mmontes11
mmontes11 / codegen.sh
Created July 30, 2021 09:54
CRD code generation
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
CODEGEN_PKG=${CODEGEN_PKG:-$(
cd "${SCRIPT_ROOT}"
ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator
package v1alpha1
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Echo struct {
metav1.TypeMeta `json:",inline"`
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: echos.mmontes.io
spec:
group: mmontes.io
names:
kind: Echo
listKind: EchoList
plural: echos
name: Release
on:
push:
branches:
- main
jobs:
release:
name: Release
#!/bin/bash
set -e
echo "☸️ Updating repos..."
helm repo add gotway https://charts.gotway.duckdns.org
helm repo add mmontes https://charts.mmontes-dev.duckdns.org
helm repo add chartmuseum https://chartmuseum.github.io/charts
helm repo update
{{ $fullName := include "gotway.fullname" . }}
{{ $selectorLabels := include "gotway.selectorLabels" . }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $fullName }}
labels:
{{ include "gotway.labels" . | nindent 4 }}
spec:
selector:
nameOverride: ""
fullnameOverride: ""
image:
repository: gotwaygateway/gotway
pullPolicy: IfNotPresent
tag: "v0.0.2"
service:
type: NodePort
apiVersion: v2
name: gotway
description: A simple, lightweight and blazingly fast API gateway
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as