Skip to content

Instantly share code, notes, and snippets.

View liangrog's full-sized avatar
🎯
Focusing

liangrog

🎯
Focusing
View GitHub Profile
@liangrog
liangrog / client-go-custom-controller-workqueue-example.go
Last active January 25, 2024 03:24
client-go-custom-controller-workqueue-example
package main
import (
"flag"
"fmt"
"time"
"k8s.io/klog"
"k8s.io/api/core/v1"
#!/bin/bash -e
CURRENT_DIR=$(pwd)
GEN_DIR=$(dirname $0)
REPO_DIR="$CURRENT_DIR/$GEN_DIR/../.."
PROJECT_MODULE="github.com/superman/demo"
IMAGE_NAME="kubernetes-codegen:latest"
CUSTOM_RESOURCE_NAME="foo"
@liangrog
liangrog / kce-bin-dockerfile
Created December 20, 2018 04:31
kce-bin-dockerfile
FROM golang:1.11.2
ENV GO111MODULE=off
RUN go get k8s.io/code-generator; exit 0
RUN go get k8s.io/apimachinery; exit 0
ARG repo="${GOPATH}/src/github.com/superman/demo"
RUN mkdir -p $repo
@liangrog
liangrog / k8s-code-gen-tags
Last active May 30, 2024 03:26
kubernetes code generator tags
// +genclient - generate default client verb functions (create, update, delete, get, list, update, patch, watch and depending on the existence of .Status field in the type the client is generated for also updateStatus).
// +genclient:nonNamespaced - all verb functions are generated without namespace.
// +genclient:onlyVerbs=create,get - only listed verb functions will be generated.
// +genclient:skipVerbs=watch - all default client verb functions will be generated except watch verb.
// +genclient:noStatus - skip generation of updateStatus verb even thought the .Status field exists.
@liangrog
liangrog / kce-pkg-apis-foo-v1-register.go
Last active December 20, 2018 04:21
kce-pkg-apis-foo-v1-register
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// Define your schema name and the version
var SchemeGroupVersion = schema.GroupVersion{
@liangrog
liangrog / pseudo-awesome-provisioner-main.go
Last active May 9, 2018 22:12
pseudo codes for implementing external-storage provisioner interface used in Medium article
package main
import (
"flag"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"