Skip to content

Instantly share code, notes, and snippets.

View abohmeed's full-sized avatar
💭
Life is a Poker game not a Chess one

Ahmed ElFakharany abohmeed

💭
Life is a Poker game not a Chess one
View GitHub Profile
cat <<EOF | kubectl apply -f -
apiVersion: certificates.k8s.io/v1beta1
kind: CertificateSigningRequest
metadata:
name: tempcsr
spec:
request: $(cat server.csr | base64 | tr -d '\n')
groups:
- system:authenticated
EOF
config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
clientset, err := kubernetes.NewForConfig(config)
check("The following error occured while loading the Kube Config file", err)
csr := &certificates.CertificateSigningRequest{
ObjectMeta: v1.ObjectMeta{
Name: "tempcsr",
},
Spec: certificates.CertificateSigningRequestSpec{
Groups: []string{
"system:authenticated",
func findKubeConfig() (string, error) {
env := os.Getenv("KUBECONFIG")
if env != "" {
return env, nil
}
path, err := homedir.Expand("~/.kube/config")
if err != nil {
return "", err
}
return path, nil
@abohmeed
abohmeed / main.go
Last active June 1, 2020 10:54
k8suser gists
key, err := rsa.GenerateKey(rand.Reader, 1024)
check("The following error occured while creating the RSA key", err)
keyDer := x509.MarshalPKCS1PrivateKey(key)
commonName := *usernamePtr
emailAddress := *emailPtr
org := strings.ToUpper(*orgazniationPtr)
orgUnit := strings.ToUpper(*orgUnitPtr)
city := strings.ToUpper(*cityPtr)
state := strings.ToUpper(*provincePtr)
country := strings.ToUpper(*countryPtr)