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

move Metrics adapter into the separate Deployment #506

Merged
merged 1 commit into from
Jan 28, 2020
Merged
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
4 changes: 4 additions & 0 deletions deploy/00-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: keda
File renamed without changes.
13 changes: 0 additions & 13 deletions deploy/role.yaml → deploy/10-cluster_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,3 @@ rules:
- horizontalpodautoscalers
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: keda-external-metrics-reader
rules:
- apiGroups:
- "external.metrics.k8s.io"
resources:
- '*'
verbs:
- list
12 changes: 12 additions & 0 deletions deploy/11-role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: keda-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: keda-operator
subjects:
- kind: ServiceAccount
name: keda-operator
namespace: keda
36 changes: 36 additions & 0 deletions deploy/12-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: keda-operator
name: keda-operator
namespace: keda
spec:
replicas: 1
selector:
matchLabels:
app: keda-operator
template:
metadata:
labels:
app: keda-operator
name: keda-operator
spec:
serviceAccountName: keda-operator
containers:
- name: keda-operator
image: docker.io/kedacore/keda:1.1.0
command:
- keda
args:
- '--zap-level=info'
imagePullPolicy: Always
env:
- name: WATCH_NAMESPACE
value: ""
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: "keda-operator"
12 changes: 12 additions & 0 deletions deploy/20-metrics-cluster_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: keda-external-metrics-reader
rules:
- apiGroups:
- "external.metrics.k8s.io"
resources:
- '*'
verbs:
- '*'
13 changes: 0 additions & 13 deletions deploy/role_binding.yaml → deploy/21-metrics-role_binding.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: keda-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: keda-operator
subjects:
- kind: ServiceAccount
name: keda-operator
namespace: keda
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: keda:system:auth-delegator
roleRef:
Expand Down
26 changes: 5 additions & 21 deletions deploy/operator.yaml → deploy/22-metrics-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,22 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: keda-operator
name: keda-operator
app: keda-metrics-apiserver
name: keda-metrics-apiserver
namespace: keda
spec:
replicas: 1
selector:
matchLabels:
app: keda-operator
app: keda-metrics-apiserver
template:
metadata:
labels:
app: keda-operator
name: keda-operator
app: keda-metrics-apiserver
name: keda-metrics-apiserver
spec:
serviceAccountName: keda-operator
containers:
- name: keda-operator
image: docker.io/kedacore/keda:1.1.0
command:
- keda
args:
- '--zap-level=info'
imagePullPolicy: Always
env:
- name: WATCH_NAMESPACE
value: ""
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: "keda-operator"
- name: keda-metrics-apiserver
image: docker.io/kedacore/keda-metrics-adapter:1.1.0
imagePullPolicy: Always
Expand Down
4 changes: 2 additions & 2 deletions deploy/service.yaml → deploy/23-metrics-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: Service
metadata:
name: keda-operator
name: keda-metrics-apiserver
namespace: keda
spec:
ports:
Expand All @@ -13,4 +13,4 @@ spec:
port: 80
targetPort: 8080
selector:
app: keda-operator
app: keda-metrics-apiserver
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: v1beta1.external.metrics.k8s.io
spec:
service:
name: keda-operator
name: keda-metrics-apiserver
namespace: keda
group: external.metrics.k8s.io
version: v1beta1
Expand Down
3 changes: 2 additions & 1 deletion tests/cleanup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ test('Remove Keda', t => {
const resources = [
'apiservice.apiregistration.k8s.io/v1beta1.external.metrics.k8s.io',
'deployment.apps/keda-operator',
'deployment.apps/keda-metrics-apiserver',
'clusterrole.rbac.authorization.k8s.io/keda-operator',
'clusterrole.rbac.authorization.k8s.io/keda-external-metrics-reader',
'clusterrolebinding.rbac.authorization.k8s.io/keda-operator',
'clusterrolebinding.rbac.authorization.k8s.io/keda:system:auth-delegator',
'rolebinding.rbac.authorization.k8s.io/keda-auth-reader',
'clusterrolebinding.rbac.authorization.k8s.io/keda-hpa-controller-external-metrics',
'service/keda-operator',
'service/keda-metrics-apiserver',
'serviceaccount/keda-operator',
]

Expand Down
37 changes: 26 additions & 11 deletions tests/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,43 +53,58 @@ test.serial('verifyKeda', t => {
const adapterImage = process.env.IMAGE_ADAPTER || 'docker.io/kedacore/keda-metrics-adapter:master'
let result = sh.exec('kubectl scale deployment.apps/keda-operator --namespace keda --replicas=0')
if (result.code !== 0) {
t.fail(`error scaling keda to 0. ${result}`)
t.fail(`error scaling keda operator to 0. ${result}`)
}
result = sh.exec(
'kubectl scale deployment.apps/keda-metrics-apiserver --namespace keda --replicas=0'
)
if (result.code !== 0) {
t.fail(`error scaling keda metrics server to 0. ${result}`)
}

result = sh.exec(
`kubectl set image deployment.apps/keda-operator --namespace keda keda-operator=${controllerImage}`
)
if (result.code !== 0) {
t.fail(`error updating keda image. ${result}`)
t.fail(`error updating keda operator image. ${result}`)
}

result = sh.exec(
`kubectl set image deployment.apps/keda-operator --namespace keda keda-metrics-apiserver=${adapterImage}`
`kubectl set image deployment.apps/keda-metrics-apiserver --namespace keda keda-metrics-apiserver=${adapterImage}`
)
if (result.code !== 0) {
t.fail(`error updating keda image. ${result}`)
t.fail(`error updating keda metrics server image. ${result}`)
}

result = sh.exec('kubectl scale deployment.apps/keda-operator --namespace keda --replicas=1')
if (result.code !== 0) {
t.fail(`error scaling keda to 1. ${result}`)
t.fail(`error scaling keda operator to 1. ${result}`)
}

result = sh.exec('kubectl scale deployment.apps/keda-metrics-apiserver --namespace keda --replicas=1')
if (result.code !== 0) {
t.fail(`error scaling keda metrics server to 1. ${result}`)
}

let success = false
for (let i = 0; i < 20; i++) {
let result = sh.exec(
let resultOperator = sh.exec(
'kubectl get deployment.apps/keda-operator --namespace keda -o jsonpath="{.status.readyReplicas}"'
)
const parsed = parseInt(result.stdout, 10)
if (isNaN(parsed) || parsed != 1) {
let resultMetrics = sh.exec(
'kubectl get deployment.apps/keda-metrics-apiserver --namespace keda -o jsonpath="{.status.readyReplicas}"'
)
const parsedOperator = parseInt(resultOperator.stdout, 10)
const parsedMetrics = parseInt(resultMetrics.stdout, 10)
if (isNaN(parsedOperator) || parsedOperator != 1 || isNaN(parsedMetrics) || parsedMetrics != 1) {
t.log(`Keda is not ready. sleeping`)
sh.exec('sleep 1s')
} else if (parsed == 1) {
t.log('keda is running 1 pod')
} else if (parsedOperator == 1 && parsedMetrics == 1) {
t.log('keda is running 1 pod for operator and 1 pod for metrics server')
success = true
break
}
}

t.true(success, 'expected keda deployment to start 1 pod successfully with kedacore/keda:master')
t.true(success, 'expected keda deployments to start 2 pods successfully')
})