Skip to content

Instantly share code, notes, and snippets.

View didil's full-sized avatar

Adil H didil

View GitHub Profile
@didil
didil / bucket.go
Last active November 19, 2020 17:58
Bucket CRD in GO
// BucketSpec defines the desired state of Bucket
type BucketSpec struct {
// Cloud platform
// +kubebuilder:validation:Enum=gcp
// +kubebuilder:validation:Required
Cloud BucketCloud `json:"cloud"`
// FullName is the cloud storage bucket full name
// +kubebuilder:validation:Required
FullName string `json:"fullName"`
@didil
didil / webhookconf.yaml
Created October 5, 2020 16:38
Hello Webhook Conf
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: "hello-webhook.leclouddev.com"
webhooks:
- name: "hello-webhook.leclouddev.com"
objectSelector:
matchLabels:
hello: "true"
rules:
@didil
didil / service.yaml
Created October 5, 2020 16:37
Hello Webhook Service
apiVersion: v1
kind: Service
metadata:
name: hello-webhook-service
spec:
type: ClusterIP
selector:
app: hello-webhook
ports:
- protocol: TCP
@didil
didil / deployment.yaml
Created October 5, 2020 16:36
Hello Webhook Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-webhook-deployment
labels:
app: hello-webhook
spec:
replicas: 1
selector:
matchLabels:
@didil
didil / csr-job.yaml
Created October 5, 2020 16:33
Webhook Certificate Setup Job
apiVersion: batch/v1
kind: Job
metadata:
name: webhook-cert-setup
spec:
template:
spec:
serviceAccountName: webhook-cert-sa
containers:
- name: webhook-cert-setup
@didil
didil / hellotxt-configmap.yaml
Created October 5, 2020 16:07
Hello.txt ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: hello-configmap
data:
hello.txt: "\n /$$$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$
\ /$$ /$$$$$$ /$$$$$$ \n|__ $$__/| $$ | $$|_ $$_/ /$$__ $$ |_ $$_/
/$$__ $$ | $$ /$$/ /$$__ $$ /$$__ $$\n | $$ | $$ | $$ | $$ | $$
\ \\__/ | $$ | $$ \\__/ | $$ /$$/ | $$ \\ $$| $$ \\__/\n | $$
\ | $$$$$$$$ | $$ | $$$$$$ | $$ | $$$$$$ | $$$$$/ | $$$$$$/|
@didil
didil / mutationhandler.go
Created October 5, 2020 15:58
Mutation Handler
func (app *App) HandleMutate(w http.ResponseWriter, r *http.Request) {
admissionReview := &admissionv1.AdmissionReview{}
// read the AdmissionReview from the request json body
err := readJSON(r, admissionReview)
if err != nil {
app.HandleError(w, r, err)
return
}
@didil
didil / Makefile
Created September 25, 2020 13:45
api gateway demo Makefile
USERS_APP_VERSION=0.1.1
USERS_APP_IMAGE=gcr.io/$(PROJECT_ID)/users:$(USERS_APP_VERSION)
LOCATIONS_APP_VERSION=0.1.1
LOCATIONS_APP_IMAGE=gcr.io/$(PROJECT_ID)/locations:$(LOCATIONS_APP_VERSION)
gcp-enable-apis:
gcloud services enable cloudresourcemanager.googleapis.com --project $(PROJECT_ID)
gcloud services enable cloudbuild.googleapis.com --project $(PROJECT_ID)
gcloud services enable apigateway.googleapis.com --project $(PROJECT_ID)
@didil
didil / locations.go
Created September 25, 2020 13:36
Locations service
// BuildRouter builds the router
func BuildRouter() (*chi.Mux, error) {
r := chi.NewRouter()
// the single route in our app (would need to be moved to a "handlers" package in a production app)
r.Get("/all", func(w http.ResponseWriter, r *http.Request) {
locations := []Location{
Location{
ID: 1,
Name: "London",
@didil
didil / api.yaml
Last active September 25, 2020 13:26
Gateway OpenAPI spec
swagger: '2.0'
info:
title: gateway-demo
description: API Gateway demo with 2 cloud run backends
version: 1.0.0
schemes:
- https
produces:
- application/json
paths: