Skip to content

Instantly share code, notes, and snippets.

@mikedanese
Last active May 8, 2019
Embed
What would you like to do?
*.swp
inclusterconfig
FROM ubuntu
ADD inclusterconfig /inclusterconfig
apiVersion: v1
kind: Pod
metadata:
name: inclusterconfig
namespace: default
spec:
containers:
- args:
- sleep
- infinity
image: gcr.io/mikedanese-k8s/inclusterconfig:latest
imagePullPolicy: Always
name: inclusterconfig
resources:
requests:
cpu: 100m
stdin: true
tty: true
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-xlbtg
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
volumes:
- name: kube-api-access-xlbtg
projected:
defaultMode: 420
sources:
- serviceAccountToken:
expirationSeconds: 600
path: token
- configMap:
items:
- key: ca.crt
path: ca.crt
name: kube-root-ca.crt
- downwardAPI:
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
path: namespace
package main
import (
"flag"
"log"
"time"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/component-base/logs"
"k8s.io/klog"
)
func main() {
logs.InitLogs()
defer logs.FlushLogs()
flag.Set("v", "10")
flag.Set("logtostderr", "true")
flag.Parse()
klog.Infof("started")
cfg, err := rest.InClusterConfig()
if err != nil {
log.Fatalf("err: %v", err)
}
c := kubernetes.NewForConfigOrDie(cfg).RESTClient()
t := time.Tick(10 * time.Second)
for {
<-t
klog.Infof("one req")
c.Get().AbsPath("/healthz").Do()
}
}
inclusterconfig: main.go
go build -o inclusterconfig .
image: inclusterconfig
docker build -t gcr.io/mikedanese-k8s/inclusterconfig:latest .
push: image
docker push gcr.io/mikedanese-k8s/inclusterconfig:latest
.PHONY: inclusterconfig image push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment