Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Configure TLS for Kubernetes services #351

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 136 additions & 63 deletions kubernetes/catalog/kubernetes/kubernetes.bom

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions kubernetes/catalog/kubernetes/pods.bom
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ brooklyn.catalog:
kubectl get pod --namespace=${NAMESPACE} -l app=${NAME} --output=jsonpath='{range .items[0]}{.status.phase}'

brooklyn.enrichers:
- type: org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic$ComputeServiceIndicatorsFromChildrenAndMembers
brooklyn.config:
uniqueTag: pod-service-up-logic
enricher.service_state.children_and_members.quorum.up: "alwaysHealthy"
enricher.service_state.children_and_members.quorum.running: "alwaysHealthy"
enricher.aggregating.fromChildren: true
enricher.aggregating.fromMembers: false
enricher.suppressDuplicates: true
- type: org.apache.brooklyn.enricher.stock.Transformer
brooklyn.config:
uniqueTag: kubernetes-pod-url-publisher
Expand Down
7 changes: 4 additions & 3 deletions kubernetes/examples/kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ location:
region: ams01
identity: xxxxxxxx
credential: XXXXXXXX
privateKeyFile: ~/.ssh/softlayer.pem
privateKeyFile: "~/.ssh/softlayer.pem"
customizers:
- $brooklyn:object:
type: org.apache.brooklyn.location.jclouds.softlayer.SoftLayerSameVlanLocationCustomizer
Expand All @@ -23,13 +23,14 @@ services:
name: "kubernetes"
brooklyn.config:
kubernetes.debug: true
kubernetes.version: 1.4.3
kubernetes.version: 1.4.5
start.timeout: 30m
kubernetes.master.size: 2
kubernetes.initial.size: 4
kubernetes.max.size: 16
etcd.initial.size: 3
kubernetes.apiserver.port: 8000
kubernetes.apiserver.port: 8443
kubernetes.apiserver.protocol: "https"
kubernetes.scaling.cpu.limit: 0.80
kubernetes.recovery.stabilizationDelay: 30s
kubernetes.recovery.failOnRecurringFailuresInThisDuration: 300000
Expand Down
1 change: 1 addition & 0 deletions kubernetes/resources/kubernetes/known_tokens.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DwYThAUb63Mu4au35XHnbe3Y3cTu5u8j,admin,admin
17 changes: 13 additions & 4 deletions kubernetes/resources/kubernetes/kube-dns.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: v1
kind: Service
apiVersion: v1
metadata:
name: kube-dns
namespace: kube-system
labels:
app: kube-dns
name: kube-dns-service
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "KubeDNS"
kubernetes.io/name: "kube-dns"
spec:
selector:
app: kube-dns
Expand All @@ -30,6 +30,7 @@ metadata:
name: kube-dns-replicationcontroller
version: v20
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "kube-dns"
spec:
replicas: ${config['template.substitutions']['replicas']}
selector:
Expand Down Expand Up @@ -71,10 +72,14 @@ spec:
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 5
volumeMounts:
- mountPath: "/etc/kubernetes/kubeconfig"
name: kubeconfig
readOnly: true
args:
- --domain=${config['template.substitutions']['dns_service_domain']}.local.
- --dns-port=10053
- --kube-master-url=${config['template.substitutions']['kubernetes_url']}
- --kubecfg-file=/etc/kubernetes/kubeconfig
ports:
- containerPort: 10053
name: dns-local
Expand Down Expand Up @@ -113,4 +118,8 @@ spec:
ports:
- containerPort: 8080
protocol: TCP
dnsPolicy: Default
volumes:
- name: kubeconfig
hostPath:
path: "/etc/kubernetes/kubeconfig"
dnsPolicy: Default
26 changes: 20 additions & 6 deletions kubernetes/resources/kubernetes/kubernetes-dashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,48 @@ metadata:
app: kubernetes-dashboard
name: kubernetes-dashboard-deployment
version: v1.4.1
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "kubernetes-dashboard"
spec:
replicas: 1
selector:
matchLabels:
app: kubernetes-dashboard
kubernetes.io/cluster-service: "true"
template:
metadata:
labels:
app: kubernetes-dashboard
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
scheduler.alpha.kubernetes.io/tolerations: '[{"key":"CriticalAddonsOnly", "operator":"Exists"}]'
version: v1.4.1
kubernetes.io/cluster-service: "true"
spec:
containers:
- name: kubernetes-dashboard
image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.4.1
imagePullPolicy: Always
ports:
- containerPort: 9090
protocol: TCP
args:
- --apiserver-host=${config['template.substitutions']['kubernetes_url']}
- containerPort: 9090
protocol: TCP
volumeMounts:
- mountPath: "/etc/kubernetes/kubeconfig"
name: kubeconfig
readOnly: true
env:
- name: KUBECONFIG
value: "/etc/kubernetes/kubeconfig"
livenessProbe:
httpGet:
path: /
port: 9090
initialDelaySeconds: 30
timeoutSeconds: 30
volumes:
- name: kubeconfig
hostPath:
path: "/etc/kubernetes/kubeconfig"
---
kind: Service
apiVersion: v1
Expand All @@ -47,7 +61,7 @@ metadata:
spec:
type: NodePort
ports:
- port: 80
targetPort: 9090
- port: 80
targetPort: 9090
selector:
app: kubernetes-dashboard
4 changes: 4 additions & 0 deletions kubernetes/resources/kubernetes/policy.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user": "admin", "namespace": "*", "resource": "*", "apiGroup": "*"}}
{"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user": "kubelet", "namespace": "*", "resource": "pods", "readonly": true}}
{"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user": "kubelet", "namespace": "*", "resource": "events"}}
{"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": {"user": "*", "readonly": true, "nonResourcePath": "*"}}
51 changes: 29 additions & 22 deletions kubernetes/resources/kubernetes/prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
app: prometheus
name: prometheus-service
annotations:
prometheus.io/scrape: 'true'
prometheus.io/scrape: "true"
spec:
selector:
app: prometheus
Expand All @@ -26,12 +26,20 @@ metadata:
labels:
app: prometheus
name: prometheus-deployment
version: v1.1.3
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "prometheus"
spec:
replicas: 1
selector:
app: prometheus
kubernetes.io/cluster-service: "true"
template:
metadata:
labels:
app: prometheus
version: v1.1.3
kubernetes.io/cluster-service: "true"
spec:
containers:
- image: quay.io/prometheus/prometheus:v1.1.3
Expand Down Expand Up @@ -65,8 +73,8 @@ spec:
configMap:
name: prometheus-config
---
apiVersion: v1
kind: ConfigMap
apiVersion: v1
metadata:
name: prometheus-config
namespace: kube-system
Expand All @@ -81,38 +89,37 @@ data:
- targets:
- localhost:9090
- job_name: 'kubernetes-cluster'
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- api_servers:
- ${config['template.substitutions']['kubernetes_url']}
basic_auth:
username: prometheus
password: pr0m3th3us
- https://kubernetes.default.svc
in_cluster: true
role: apiserver
- job_name: 'kubernetes-nodes'
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- api_servers:
- ${config['template.substitutions']['kubernetes_url']}
basic_auth:
username: prometheus
password: pr0m3th3us
- https://kubernetes.default.svc
in_cluster: true
role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- source_labels: [__meta_kubernetes_role]
action: replace
target_label: kubernetes_role
- source_labels: [__address__]
regex: (.*):10250
replacement: ${r"${1}:10255"}
target_label: __address__
- job_name: 'kubernetes-service-endpoints'
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- api_servers:
- ${config['template.substitutions']['kubernetes_url']}
basic_auth:
username: prometheus
password: pr0m3th3us
- https://kubernetes.default.svc
in_cluster: true
role: endpoint
relabel_configs:
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
Expand All @@ -138,4 +145,4 @@ data:
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_service_name]
action: replace
target_label: kubernetes_name
target_label: kubernetes_name