mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 01:38:10 +00:00
deploy: Update custom metrics API name and separate into files
This commit is contained in:
parent
8dd527d821
commit
80598a8bd3
12 changed files with 146 additions and 157 deletions
|
|
@ -9,5 +9,7 @@ Example Deployment
|
||||||
documentation](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/concepts/auth.md)
|
documentation](https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/concepts/auth.md)
|
||||||
in the apiserver-builder repository.
|
in the apiserver-builder repository.
|
||||||
|
|
||||||
3. `kubectl create -f example-deployment.yaml`, modifying as necessary to
|
3. `kubectl create namespace custom-metrics` to ensure the namespace we choose to install the custom metrics adapter in.
|
||||||
|
|
||||||
|
4. `kubectl create -f manifests/`, modifying as necessary to
|
||||||
point to your prometheus server.
|
point to your prometheus server.
|
||||||
|
|
|
||||||
|
|
@ -1,156 +0,0 @@
|
||||||
kind: Namespace
|
|
||||||
apiVersion: v1
|
|
||||||
metadata:
|
|
||||||
name: custom-metrics
|
|
||||||
---
|
|
||||||
kind: ServiceAccount
|
|
||||||
apiVersion: v1
|
|
||||||
metadata:
|
|
||||||
name: custom-metrics-apiserver
|
|
||||||
namespace: custom-metrics
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
|
||||||
kind: ClusterRoleBinding
|
|
||||||
metadata:
|
|
||||||
name: custom-metrics:system:auth-delegator
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: ClusterRole
|
|
||||||
name: system:auth-delegator
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: custom-metrics-apiserver
|
|
||||||
namespace: custom-metrics
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
|
||||||
kind: RoleBinding
|
|
||||||
metadata:
|
|
||||||
name: custom-metrics-auth-reader
|
|
||||||
namespace: kube-system
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: Role
|
|
||||||
name: extension-apiserver-authentication-reader
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: custom-metrics-apiserver
|
|
||||||
namespace: custom-metrics
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
|
||||||
kind: ClusterRole
|
|
||||||
metadata:
|
|
||||||
name: custom-metrics-resource-reader
|
|
||||||
rules:
|
|
||||||
- apiGroups:
|
|
||||||
- ""
|
|
||||||
resources:
|
|
||||||
- namespaces
|
|
||||||
- pods
|
|
||||||
- services
|
|
||||||
verbs:
|
|
||||||
- get
|
|
||||||
- list
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
|
||||||
kind: ClusterRoleBinding
|
|
||||||
metadata:
|
|
||||||
name: custom-metrics-resource-reader
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: ClusterRole
|
|
||||||
name: custom-metrics-resource-reader
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: custom-metrics-apiserver
|
|
||||||
namespace: custom-metrics
|
|
||||||
---
|
|
||||||
apiVersion: extensions/v1beta1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: custom-metrics-apiserver
|
|
||||||
name: custom-metrics-apiserver
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: custom-metrics-apiserver
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: custom-metrics-apiserver
|
|
||||||
name: custom-metrics-apiserver
|
|
||||||
spec:
|
|
||||||
serviceAccountName: custom-metrics-apiserver
|
|
||||||
containers:
|
|
||||||
- name: custom-metrics-apiserver
|
|
||||||
image: directxman12/k8s-prometheus-adapter
|
|
||||||
args:
|
|
||||||
- /adapter
|
|
||||||
- --secure-port=6443
|
|
||||||
- --tls-cert-file=/var/run/serving-cert/serving.crt
|
|
||||||
- --tls-private-key-file=/var/run/serving-cert/serving.key
|
|
||||||
- --logtostderr=true
|
|
||||||
- --prometheus-url=http://prometheus.prom.svc:9090/
|
|
||||||
- --metrics-relist-interval=30s
|
|
||||||
- --rate-interval=30s
|
|
||||||
- --v=10
|
|
||||||
ports:
|
|
||||||
- containerPort: 6443
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: /var/run/serving-cert
|
|
||||||
name: volume-serving-cert
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: volume-serving-cert
|
|
||||||
secret:
|
|
||||||
secretName: cm-adapter-serving-certs
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: api
|
|
||||||
namespace: custom-metrics
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 443
|
|
||||||
targetPort: 6443
|
|
||||||
selector:
|
|
||||||
app: custom-metrics-apiserver
|
|
||||||
---
|
|
||||||
apiVersion: apiregistration.k8s.io/v1beta1
|
|
||||||
kind: APIService
|
|
||||||
metadata:
|
|
||||||
name: v1alpha1.custom-metrics.metrics.k8s.io
|
|
||||||
spec:
|
|
||||||
insecureSkipTLSVerify: true
|
|
||||||
group: custom-metrics.metrics.k8s.io
|
|
||||||
priority: 150
|
|
||||||
service:
|
|
||||||
name: api
|
|
||||||
namespace: custom-metrics
|
|
||||||
version: v1alpha1
|
|
||||||
---
|
|
||||||
# Make a ClusterRole so that the HPA controller is able to read the custom metrics this adapter provides
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
|
||||||
kind: ClusterRole
|
|
||||||
metadata:
|
|
||||||
name: custom-metrics-server-resources
|
|
||||||
rules:
|
|
||||||
- apiGroups:
|
|
||||||
- custom-metrics.metrics.k8s.io
|
|
||||||
resources: ["*"]
|
|
||||||
verbs: ["*"]
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
|
||||||
kind: ClusterRoleBinding
|
|
||||||
metadata:
|
|
||||||
name: hpa-controller-custom-metrics
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: ClusterRole
|
|
||||||
name: custom-metrics-server-resources
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: horizontal-pod-autoscaler
|
|
||||||
namespace: kube-system
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: custom-metrics:system:auth-delegator
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: ClusterRole
|
||||||
|
name: system:auth-delegator
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: custom-metrics-apiserver
|
||||||
|
namespace: custom-metrics
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: custom-metrics-auth-reader
|
||||||
|
namespace: kube-system
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: extension-apiserver-authentication-reader
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: custom-metrics-apiserver
|
||||||
|
namespace: custom-metrics
|
||||||
42
deploy/manifests/custom-metrics-apiserver-deployment.yaml
Normal file
42
deploy/manifests/custom-metrics-apiserver-deployment.yaml
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: custom-metrics-apiserver
|
||||||
|
name: custom-metrics-apiserver
|
||||||
|
namespace: custom-metrics
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: custom-metrics-apiserver
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: custom-metrics-apiserver
|
||||||
|
name: custom-metrics-apiserver
|
||||||
|
spec:
|
||||||
|
serviceAccountName: custom-metrics-apiserver
|
||||||
|
containers:
|
||||||
|
- name: custom-metrics-apiserver
|
||||||
|
image: directxman12/k8s-prometheus-adapter
|
||||||
|
args:
|
||||||
|
- /adapter
|
||||||
|
- --secure-port=6443
|
||||||
|
- --tls-cert-file=/var/run/serving-cert/serving.crt
|
||||||
|
- --tls-private-key-file=/var/run/serving-cert/serving.key
|
||||||
|
- --logtostderr=true
|
||||||
|
- --prometheus-url=http://prometheus.prom.svc:9090/
|
||||||
|
- --metrics-relist-interval=30s
|
||||||
|
- --rate-interval=5m
|
||||||
|
- --v=10
|
||||||
|
ports:
|
||||||
|
- containerPort: 6443
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /var/run/serving-cert
|
||||||
|
name: volume-serving-cert
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: volume-serving-cert
|
||||||
|
secret:
|
||||||
|
secretName: cm-adapter-serving-certs
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: custom-metrics-resource-reader
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: ClusterRole
|
||||||
|
name: custom-metrics-resource-reader
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: custom-metrics-apiserver
|
||||||
|
namespace: custom-metrics
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
kind: ServiceAccount
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: custom-metrics-apiserver
|
||||||
|
namespace: custom-metrics
|
||||||
11
deploy/manifests/custom-metrics-apiserver-service.yaml
Normal file
11
deploy/manifests/custom-metrics-apiserver-service.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: custom-metrics-apiserver
|
||||||
|
namespace: custom-metrics
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 443
|
||||||
|
targetPort: 6443
|
||||||
|
selector:
|
||||||
|
app: custom-metrics-apiserver
|
||||||
13
deploy/manifests/custom-metrics-apiservice.yaml
Normal file
13
deploy/manifests/custom-metrics-apiservice.yaml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
apiVersion: apiregistration.k8s.io/v1beta1
|
||||||
|
kind: APIService
|
||||||
|
metadata:
|
||||||
|
name: v1beta1.custom.metrics.k8s.io
|
||||||
|
spec:
|
||||||
|
service:
|
||||||
|
name: custom-metrics-apiserver
|
||||||
|
namespace: custom-metrics
|
||||||
|
group: custom.metrics.k8s.io
|
||||||
|
version: v1beta1
|
||||||
|
insecureSkipTLSVerify: true
|
||||||
|
groupPriorityMinimum: 100
|
||||||
|
versionPriority: 100
|
||||||
9
deploy/manifests/custom-metrics-cluster-role.yaml
Normal file
9
deploy/manifests/custom-metrics-cluster-role.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
name: custom-metrics-server-resources
|
||||||
|
rules:
|
||||||
|
- apiGroups:
|
||||||
|
- custom.metrics.k8s.io
|
||||||
|
resources: ["*"]
|
||||||
|
verbs: ["*"]
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
name: custom-metrics-resource-reader
|
||||||
|
rules:
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- namespaces
|
||||||
|
- pods
|
||||||
|
- services
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: hpa-controller-custom-metrics
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: ClusterRole
|
||||||
|
name: custom-metrics-server-resources
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: horizontal-pod-autoscaler
|
||||||
|
namespace: kube-system
|
||||||
Loading…
Add table
Add a link
Reference in a new issue