Skip to content

POD Autoscaling

Deploy Pod Autoscaling exmaple with Chaos Professor

1
oc process -f https://examples.openshift.pub/deploy/autoscaling/pod-autoscaling-template.yaml | oc apply -f -
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
---
kind: Template
apiVersion: template.openshift.io/v1
metadata:
  name: pod-autoscaling-example
  creationTimestamp:
  annotations:
    description: Pod Autoscaling exmaple with Chaos Professor
    iconClass: icon-tomcat
    tags: tomcat,tomcat7,java,jboss,xpaas,autoscaling,chaos-professor
    version: 0.0.1
objects:
- kind: ImageStream
  apiVersion: v1
  metadata:
    name: redhat-openjdk18-openshift
  spec:
    dockerImageRepository: registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift
    tags:
    - name: '1.0'
      annotations:
        description: OpenJDK S2I images.
        iconClass: icon-jboss
        tags: builder,java,xpaas
        supports: java:8,xpaas:1.0
        sampleRepo: https://github.com/jboss-openshift/openshift-quickstarts
        sampleContextDir: undertow-servlet
        version: '1.0'
- kind: Service
  apiVersion: v1
  spec:
    ports:
    - port: 8080
      targetPort: 8080
    selector:
      deploymentConfig: "${APPLICATION_NAME}"
  metadata:
    name: "${APPLICATION_NAME}"
    labels:
      application: "${APPLICATION_NAME}"
    annotations:
      description: The web server's http port.
- kind: Route
  apiVersion: v1
  id: "${APPLICATION_NAME}-http"
  metadata:
    name: "${APPLICATION_NAME}"
    labels:
      application: "${APPLICATION_NAME}"
    annotations:
      description: Route for application's http service.
  spec:
    host: "${HOSTNAME_HTTP}"
    to:
      name: "${APPLICATION_NAME}"
- kind: ImageStream
  apiVersion: v1
  metadata:
    name: "${APPLICATION_NAME}"
    labels:
      application: "${APPLICATION_NAME}"
- kind: BuildConfig
  apiVersion: v1
  metadata:
    name: "${APPLICATION_NAME}"
    labels:
      application: "${APPLICATION_NAME}"
  spec:
    source:
      type: Git
      git:
        uri: "${SOURCE_REPOSITORY_URL}"
        ref: "${SOURCE_REPOSITORY_REF}"
      contextDir: "${CONTEXT_DIR}"
    strategy:
      type: Source
      sourceStrategy:
        forcePull: true
        from:
          kind: ImageStreamTag
          name: redhat-openjdk18-openshift:latest
    output:
      to:
        kind: ImageStreamTag
        name: "${APPLICATION_NAME}:latest"
    triggers:
    - type: GitHub
      github:
        secret: "${GITHUB_WEBHOOK_SECRET}"
    - type: Generic
      generic:
        secret: "${GENERIC_WEBHOOK_SECRET}"
    - type: ImageChange
      imageChange: {}
    - type: ConfigChange
- kind: DeploymentConfig
  apiVersion: v1
  metadata:
    name: "${APPLICATION_NAME}"
    labels:
      application: "${APPLICATION_NAME}"
  spec:
    strategy:
      type: Recreate
    triggers:
    - type: ImageChange
      imageChangeParams:
        automatic: true
        containerNames:
        - "${APPLICATION_NAME}"
        from:
          kind: ImageStream
          name: "${APPLICATION_NAME}"
    - type: ConfigChange
    replicas: 1
    selector:
      deploymentConfig: "${APPLICATION_NAME}"
    template:
      metadata:
        name: "${APPLICATION_NAME}"
        labels:
          deploymentConfig: "${APPLICATION_NAME}"
          application: "${APPLICATION_NAME}"
      spec:
        terminationGracePeriodSeconds: 60
        containers:
        - name: "${APPLICATION_NAME}"
          image: "${APPLICATION_NAME}"
          resources:
            limits:
              cpu: 500m
              memory: 512Mi
            requests:
              cpu: 500m
              memory: 512Mi
          imagePullPolicy: Always
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: "/"
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 25
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
          ports:
          - name: jolokia
            containerPort: 8778
            protocol: TCP
          - name: http
            containerPort: 8080
            protocol: TCP
          env:
          - name: JWS_ADMIN_USERNAME
            value: "${JWS_ADMIN_USERNAME}"
          - name: JWS_ADMIN_PASSWORD
            value: "${JWS_ADMIN_PASSWORD}"
- kind: HorizontalPodAutoscaler
  apiVersion: autoscaling/v1
  metadata:
    name: "${APPLICATION_NAME}"
    labels:
      application: "${APPLICATION_NAME}"
  spec:
    scaleTargetRef:
      kind: DeploymentConfig
      name: "${APPLICATION_NAME}"
      apiVersion: v1
      subresource: scale
    minReplicas: ${{HorizontalPodAutoscaler_MIN_REPLICAS}}
    maxReplicas: ${{HorizontalPodAutoscaler_MAX_REPLICAS}}
    cpuUtilization:
      targetCPUUtilizationPercentage: "${HorizontalPodAutoscaler_CPU_TARGET_PERCENTAGE}"
parameters:
- name: APPLICATION_NAME
  description: The name for the application.
  value: choas-professor
  required: true
- name: HorizontalPodAutoscaler_MIN_REPLICAS
  description: 'HorizontalPodAutoscaler: min replicas'
  value: "1"
  required: true
- name: HorizontalPodAutoscaler_MAX_REPLICAS
  description: 'HorizontalPodAutoscaler: max replicas'
  value: "4"
  required: true
- name: HorizontalPodAutoscaler_CPU_TARGET_PERCENTAGE
  description: 'HorizontalPodAutoscaler: targetPercentage of cpuUtilization'
  value: '60'
  required: true
- name: HOSTNAME_HTTP
  description: 'Custom hostname for http service route.  Leave blank for default hostname,
    e.g.: <application-name>-<project>.<default-domain-suffix>'
- name: SOURCE_REPOSITORY_URL
  description: Git source URI for application
  value: https://github.com/ConSol/chaos-professor.git
  required: true
- name: SOURCE_REPOSITORY_REF
  description: Git branch/tag reference
  value: master
- name: CONTEXT_DIR
  description: Path within Git project to build; empty for root project directory.
  value: ''
- name: GITHUB_WEBHOOK_SECRET
  description: GitHub trigger secret
  generate: expression
  from: "[a-zA-Z0-9]{8}"
  required: true
- name: GENERIC_WEBHOOK_SECRET
  description: Generic build trigger secret
  generate: expression
  from: "[a-zA-Z0-9]{8}"
  required: true
labels:
  template: jws30-tomcat7-basic-s2i
  xpaas: 1.2.0

Test autoscaling

1
2
3
4
# Only 4fun
ab 'http://choas-professor-omd.paas.osp.consol.de/chaos/heapheap?size=500&time=10000'
ab 'http://choas-professor-omd.paas.osp.consol.de/chaos/cpu?threads=100&keepAlive=20000'
ab -c 10 -n 100 'http://choas-professor-omd.paas.osp.consol.de/chaos/cpu?threads=100&keepAlive=200'

Delete all

1
2
oc get all -o name | xargs -n1  oc delete
oc delete hpa/choas-professor

Last update: June 6, 2022
Back to top