Created
April 30, 2019 01:55
-
-
Save jwhitlark/8e42baadbd86147547d1cdb08c81191c to your computer and use it in GitHub Desktop.
Access Kubernetes API from inside a pod with clojure, clj-http, and a custom ca.crt, with help from aphyr's less-awful-ssl
This file contains 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
;; less-awful-ssl {:mvn/version "1.0.4"} | |
;; clj-http {:mvn/version "3.9.1"} | |
(let [trust-store (less.awful.ssl/trust-store (clojure.java.io/file "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")) | |
bearer-token (format "Bearer %s" (slurp "/var/run/secrets/kubernetes.io/serviceaccount/token")) | |
kube-api-host (System/getenv "") | |
kube-api-port (System/getenv "")] | |
(clj-http.client/get | |
(format "https://%s:%s/apis/<something-protected>" kube-api-host kube-api-port) | |
{:trust-store trust-store | |
:headers {:authorization bearer-token}}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oops, forgot
KUBERNETES_SERVICE_HOST
KUBERNETES_SERVICE_PORT