Skip to content

Commit

Permalink
Added files needed for prometheus installation
Browse files Browse the repository at this point in the history
  • Loading branch information
arshiagg committed Aug 7, 2017
1 parent 9b76062 commit c1118ac
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cluster/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
c.vm.network :private_network, ip: node_addr, virtualbox__intnet: 'true', auto_config: false

c.vm.provider 'virtualbox' do |v|
v.memory = node_orc == ORC_KUBEADM && master_ips.include?(node_addr) ? 2048 : 512
v.memory = node_orc == ORC_KUBEADM && master_ips.include?(node_addr) ? 2048 : 512
# make all nics 'virtio' to take benefit of builtin vlan tag
# support, which otherwise needs to be enabled in Intel drivers,
# which are used by default by virtualbox
Expand Down
90 changes: 90 additions & 0 deletions install/k8s/k8s1.6/contiv-prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Gives Prometheus permission to share the cluster
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: prometheus
namespace: kube-system
rules:
- apiGroups: [""]
resources:
- nodes
- nodes/proxy
- services
- endpoints
- pods
verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]
---
# Prometheus is a process and hence needs service account access
apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus
namespace: kube-system
# Binds Prometheus to the kube-system namespace
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: prometheus
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus
subjects:
- kind: ServiceAccount
name: prometheus
namespace: kube-system
# Deploy prometheus as a replicaset with one container
---
apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
name: contiv-prometheus
namespace: kube-system
labels:
k8s-app: contiv-prometheus
spec:
replicas: 1
template:
metadata:
name: contiv-prometheus
labels:
k8s-app: contiv-prometheus
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
nodeSelector:
node-role.kubernetes.io/master: ""
containers:
- name: contiv-prometheus
image: prom/prometheus
volumeMounts:
- mountPath: /etc/prometheus
name: var-contiv
volumes:
- name: var-contiv
hostPath:
path: /var/contiv
serviceAccountName: prometheus
# Expose prometheus as a service
---
apiVersion: v1
kind: Service
metadata:
name: prometheus
namespace: kube-system
spec:
type: NodePort
selector:
k8s-app: contiv-prometheus
ports:
- protocol: TCP
port: 9090
nodePort: 30000

4 changes: 4 additions & 0 deletions install/k8s/k8s1.6/contiv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ spec:
labels:
k8s-app: contiv-netplugin
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '4567'
scheduler.alpha.kubernetes.io/critical-pod: ''
spec:
hostNetwork: true
Expand All @@ -140,6 +142,8 @@ spec:
# Runs netplugin container on each Kubernetes node. This
# container programs network policy and routes on each
# host.
- name: sinatra-exporter
image: arshiagg/sinatra
- name: contiv-netplugin
image: contiv/netplugin:__CONTIV_VERSION__
args:
Expand Down
28 changes: 28 additions & 0 deletions install/k8s/k8s1.6/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Prometheus configuration to scrape all netplugin endpoints every 5 seconds
scrape_configs:
- job_name: 'kubernetes-pods'

kubernetes_sd_configs:
- role: pod

relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
target_label: __address__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: kubernetes_pod_name

0 comments on commit c1118ac

Please sign in to comment.