Skip to content

Commit

Permalink
refactor: switch back to podscales (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
lterrac authored Mar 4, 2021
1 parent 41d2130 commit ec22791
Show file tree
Hide file tree
Showing 69 changed files with 1,162 additions and 1,260 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/official-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
- development
tags:
- "containerscale-controller/v*"
- "podscale-controller/v*"
- "pod-autoscaler/v*"

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ vendor/
# binaries
pkg/*/pod-autoscaler
pkg/*/pod-replicas-updater
pkg/*/containerscale-controller
pkg/*/podscale-controller
pkg/*/http-metrics
pkg/*/metrics-exposer
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MAKEFLAGS += --no-print-directory
COMPONENTS = pod-replicas-updater pod-autoscaler containerscale-controller
COMPONENTS = pod-replicas-updater pod-autoscaler podscale-controller

ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand All @@ -12,7 +12,7 @@ endif
all: build test coverage manifests release clean

# Build binary
build: fmt manifests test vet
build: fmt test vet
$(call action, build)

coverage:
Expand All @@ -29,7 +29,7 @@ fmt:

install: install-crds install-rbac

install-crds: manifests
install-crds:
@echo "install CRDs manifests"
@kubectl apply -f config/crd/bases

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The controllers are freely inspired from [sample-controller](https://github.com/
- [Contention Manager](pkg/contention-manager/README.md)
- [Pod Replicas Updater](pkg/pod-replicas-updater/README.md)
- [Pod Resource Updater](pkg/pod-resource-updater/README.md)
- [Containerscale Controller](pkg/containerscale-controller/README.md)
- [PodScale Controller](pkg/podscale-controller/README.md)
- [Recommender](pkg/recommender/README.md)

# CRDs code generation
Expand Down
4 changes: 2 additions & 2 deletions artifacts/example-podscale.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: systemautoscaler.polimi.it/v1beta1
kind: ContainerScale
kind: PodScale
metadata:
name: example-containerscale
name: example-podscale
spec:
serviceLevelAgreement:
name: example-sla
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: containerscales.systemautoscaler.polimi.it
name: podscales.systemautoscaler.polimi.it
spec:
group: systemautoscaler.polimi.it
names:
kind: ContainerScale
listKind: ContainerScaleList
plural: containerscales
singular: containerscale
kind: PodScale
listKind: PodScaleList
plural: podscales
singular: podscale
preserveUnknownFields: false
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: ContainerScale defines the mapping between a `ServiceLevelAgreement`
description: PodScale defines the mapping between a `ServiceLevelAgreement`
and a `Pod` matching the selector. It also keeps track of the resource values
computed by `Recommender` and adjusted by `Contention Manager`.
properties:
Expand All @@ -37,7 +37,7 @@ spec:
metadata:
type: object
spec:
description: ContainerScaleSpec is the spec for a ContainerScale resource
description: PodScaleSpec is the spec for a PodScale resource
properties:
container:
type: string
Expand All @@ -50,49 +50,24 @@ spec:
x-kubernetes-int-or-string: true
description: ResourceList is a set of (resource name, quantity) pairs.
type: object
namespace:
type: string
pod:
description: PodRef is a reference to a pod
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: string
service:
description: ServiceRef is a reference to a service
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: string
serviceLevelAgreement:
description: SLARef is a reference to a service level agreement
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: string
required:
- container
- namespace
- pod
- service
- serviceLevelAgreement
type: object
status:
description: ContainerScaleStatus contains the resources patched by the
`Contention Manager` according to the available node resources and other
pods' SLA
description: PodScaleStatus contains the resources patched by the `Contention
Manager` according to the available node resources and other pods' SLA
properties:
actual:
additionalProperties:
Expand Down
12 changes: 6 additions & 6 deletions config/permissions/podscale-controller.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: containerscale-controller
name: podscale-controller
namespace: kube-system
automountServiceAccountToken: false
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: system-autoscaler:containerscale-manager
name: system-autoscaler:podscale-manager
rules:
- apiGroups: [""]
resources: ["pods", "services", "nodes"]
Expand All @@ -20,19 +20,19 @@ rules:
resources: ["servicelevelagreements"]
verbs: ["get", "watch", "list"]
- apiGroups: ["systemautoscaler.polimi.it"]
resources: ["containerscales"]
resources: ["podscales"]
verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system-autoscaler:containerscale-manager
name: system-autoscaler:podscale-manager
subjects:
- kind: ServiceAccount
name: containerscale-controller
name: podscale-controller
namespace: kube-system
apiGroup: ""
roleRef:
kind: ClusterRole
name: system-autoscaler:containerscale-manager
name: system-autoscaler:podscale-manager
apiGroup: rbac.authorization.k8s.io
2 changes: 1 addition & 1 deletion examples/benchmark/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ kubectl apply -f application
kubectl apply -f metrics
kubectl apply -f system-autoscaler

kubectl cp kube-system/pod-autoscaler-578b5988c8-52brq:var/containerscale.json containerscale.json -c pod-autoscaler
kubectl cp kube-system/pod-autoscaler-578b5988c8-52brq:var/podscale.json podscale.json -c pod-autoscaler
kubectl exec postgres-statefulset-0 -- psql -d awesomedb -U amazinguser -c "\copy response_information to /response.csv delimiter ',' csv header;"
kubectl cp postgres-statefulset-0:response.csv response.csv
2 changes: 1 addition & 1 deletion examples/benchmark/monitoring/monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rules:
resources: ["servicelevelagreements"]
verbs: ["get", "watch", "list"]
- apiGroups: ["systemautoscaler.polimi.it"]
resources: ["containerscales"]
resources: ["podscales"]
verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
24 changes: 12 additions & 12 deletions examples/benchmark/system-autoscaler/containerscale-controller.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: containerscale-controller
name: podscale-controller
namespace: kube-system
automountServiceAccountToken: false
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: system-autoscaler:containerscale-controller
name: system-autoscaler:podscale-controller
rules:
- apiGroups: [""]
resources: ["pods", "services", "nodes"]
Expand All @@ -20,45 +20,45 @@ rules:
resources: ["servicelevelagreements"]
verbs: ["get", "watch", "list"]
- apiGroups: ["systemautoscaler.polimi.it"]
resources: ["containerscales"]
resources: ["podscales"]
verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system-autoscaler:containerscale-controller
name: system-autoscaler:podscale-controller
subjects:
- kind: ServiceAccount
name: containerscale-controller
name: podscale-controller
namespace: kube-system
apiGroup: ""
roleRef:
kind: ClusterRole
name: system-autoscaler:containerscale-controller
name: system-autoscaler:podscale-controller
apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: containerscale-controller
name: podscale-controller
namespace: kube-system
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: containerscale-controller
app: podscale-controller
replicas: 1
template:
metadata:
labels:
app: containerscale-controller
app: podscale-controller
spec:
automountServiceAccountToken: true
serviceAccountName: containerscale-controller
serviceAccountName: podscale-controller
containers:
- name: containerscale-controller
image: systemautoscaler/containerscale-controller:0.1.0
- name: podscale-controller
image: systemautoscaler/podscale-controller:0.1.0
imagePullPolicy: Always
resources:
limits:
Expand Down
2 changes: 1 addition & 1 deletion examples/benchmark/system-autoscaler/pod-autoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rules:
resources: ["servicelevelagreements"]
verbs: ["get", "watch", "list"]
- apiGroups: ["systemautoscaler.polimi.it"]
resources: ["containerscales"]
resources: ["podscales"]
verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
12 changes: 6 additions & 6 deletions examples/podscale-controller.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: containerscale-controller
name: podscale-controller
namespace: kube-system
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: containerscale-controller
app: podscale-controller
replicas: 1
template:
metadata:
labels:
app: containerscale-controller
app: podscale-controller
spec:
automountServiceAccountToken: true
serviceAccountName: containerscale-controller
serviceAccountName: podscale-controller
containers:
- name: containerscale-controller
image: systemautoscaler/containerscale-controller:0.1.0
- name: podscale-controller
image: systemautoscaler/podscale-controller:0.1.0
imagePullPolicy: Always
ports:
- containerPort: 443
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/systemautoscaler/v1beta1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ServiceLevelAgreement{},
&ServiceLevelAgreementList{},
&ContainerScale{},
&ContainerScaleList{},
&PodScale{},
&PodScaleList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down
Loading

0 comments on commit ec22791

Please sign in to comment.