Last active
May 8, 2019 18:54
-
-
Save mikedanese/883353239d898aaf2cccffabc7afe19b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.swp | |
inclusterconfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu | |
ADD inclusterconfig /inclusterconfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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