Skip to content

Commit

Permalink
Merge branch 'master' into revert-previous-change-remove-service-port…
Browse files Browse the repository at this point in the history
…-override
  • Loading branch information
aslafy-z committed Jul 6, 2023
2 parents 6f6b0c9 + 438792b commit ada6b85
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 13 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,26 @@

All notable changes to this project will be documented here.

### v2.1.14
### v2.1.19
- Fix: Reverts [PR-240](https://github.com/stakater/application/pull/240), This can already be configured via `paths` [PR-247](https://github.com/stakater/application/pull/247)

### v2.1.18
- feat: Add vertical pod autoscaler template [PR-249](https://github.com/stakater/application/pull/249)

### v2.1.17
- feat: allow overriding revisionHistoryLimit [PR-257](https://github.com/stakater/application/pull/257)

> Caution: This PR changes the default value for `revisionHistoryLimit` from 10 to 2.
### v2.1.16
- fix: optional service account [PR-213](https://github.com/stakater/application/pull/213)

### v2.1.15
- fix: allow setting arbitrary resource constraints [PR-255](https://github.com/stakater/application/pull/255)

### v2.1.14
- feat: allow overriding clusterIP [PR-258](https://github.com/stakater/application/pull/258)

### v2.1.13
- Fix: make deployment.image.tag and job.image.tag optional [PR-234](https://github.com/stakater/application/pull/234)

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ To uninstall the chart:
| deployment.env | Environment variables to be passed to the app container | `{}` |
| deployment.volumes | Volumes to be added to the pod | `{}` |
| deployment.volumeMounts | Mount path for Volumes | `{}` |
| deployment.revisionHistoryLimit | The number of old history to retain to allow rollback | `2` |
| deployment.command | Command for primary container of deployment | `[]` |
| deployment.args | Arg for primary container of deployment | `[]` |
| deployment.tolerations | Taint tolerations for nodes | `[]` |
Expand Down Expand Up @@ -204,6 +205,7 @@ Periodic probe of container liveness. Container will be restarted if the probe f
| service.annotations | Annotations for service | `{}` |
| service.ports | Ports for applications service | - port: 8080<br>&nbsp;&nbsp;name: http<br>&nbsp;&nbsp;protocol: TCP<br>&nbsp;&nbsp;targetPort: 8080 |
| service.type | Type of service | `ClusterIP` |
| service.clusterIP | Fixed IP for a ClusterIP service. Set to `None` for an headless service. | `null` |



Expand Down Expand Up @@ -303,6 +305,16 @@ Stakater [Forecastle](https://github.com/stakater/Forecastle) parameters
| autoscaling.maxReplicas | Sets maximum replica count when autoscaling is enabled | `10` |
| autoscaling.metrics | Configuration for hpa metrics, set when autoscaling is enabled | `{}` |

### VPA - Vertical Pod Autoscaler Parameters

| Name | Description | Value |
| ------------------------ | -------------------------------------------------------------------------------------------- | --------------- |
| vpa.enabled | Enable vertical pod autoscaler | `false` |
| vpa.additionalLabels | Labels for vertical pod autoscaler | `{}` |
| vpa.annotations | Annotations for vertical pod autoscaler | `{}` |
| vpa.containerPolicies | container policies for individual containers. | `[]` |


### EndpointMonitor Paramaters

Stakater [IngressMonitorController](https://github.com/stakater/IngressMonitorController) EndpointMonitor parameters
Expand Down
22 changes: 22 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ imc_namespace = "stakater-ingress-monitor-controller"
namespace_create(imc_namespace)
helm_resource('imc', 'oci://ghcr.io/stakater/charts/ingress-monitor-controller', namespace=imc_namespace,flags=['--set','developmentMode=true'])

# Install IMC Config
local_resource(
'imc-config',
cmd='helm upgrade --install ingress-monitor-controller-config -n {} oci://ghcr.io/stakater/charts/ingress-monitor-controller-config --set developmentMode=true'.format(imc_namespace)
)

# Install Forecastle
forecastle_namespace = "stakater-forecastle"
namespace_create(forecastle_namespace)
Expand All @@ -40,5 +46,21 @@ local_resource(
cmd='helm install grafana-operator -n grafana-operator oci://ghcr.io/stakater/charts/grafana-operator --version=0.0.1 --set operator.installPlanApproval=Automatic'
)

# Install openshift-vertical-pod-autoscaler
vpa_namespace = "openshift-vertical-pod-autoscaler"
namespace_create(vpa_namespace)
local_resource(
'openshift-vertical-pod-autoscaler',
cmd='helm install openshift-vertical-pod-autoscaler -n openshift-vertical-pod-autoscaler oci://ghcr.io/stakater/charts/openshift-vertical-pod-autoscaler'
)

# Wait until VPA CRD becomes available
local_resource(
'wait-for-crds',
cmd='timeout 300s bash -c "until kubectl wait --for condition=Established crd/verticalpodautoscalers.autoscaling.k8s.io; do sleep 10; done"',
resource_deps=[
'openshift-vertical-pod-autoscaler'
])

# Install cert-manager
# it exists already
5 changes: 5 additions & 0 deletions Tiltfile-delete
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def delete_external_secrets_operator():
print('Deleting external-secrets operator')
local('helm uninstall external-secrets-operator -n external-secrets-operator')

def delete_openshift_vertical_pod_autoscaler():
print('Uninstalling openshift-vertical-pod-autoscaler')
local('helm uninstall openshift-vertical-pod-autoscaler -n openshift-vertical-pod-autoscaler')

def delete_imc_crds():
print('Deleting imc crds')
local('oc get crds -o name | grep \'endpointmonitor\\.stakater\\.com\' | xargs -r -n 1 oc delete')
Expand All @@ -34,6 +38,7 @@ def delete_grafana_crds():

delete_grafana_operator()
delete_external_secrets_operator()
delete_openshift_vertical_pod_autoscaler()
delete_imc_crds()
delete_forecastle_crds()
delete_ss_crds()
Expand Down
2 changes: 1 addition & 1 deletion application/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type: application

# Helm chart Version

version: 2.1.13
version: 2.1.17


keywords:
Expand Down
20 changes: 11 additions & 9 deletions application/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if (.Values.deployment).enabled }}
{{- if .Values.deployment.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -28,6 +28,9 @@ spec:
{{- if .Values.deployment.strategy }}
strategy:
{{ toYaml .Values.deployment.strategy | indent 4 }}
{{- end }}
{{- if not (kindIs "invalid" .Values.deployment.revisionHistoryLimit) }}
revisionHistoryLimit: {{ .Values.deployment.revisionHistoryLimit }}
{{- end }}
template:
metadata:
Expand Down Expand Up @@ -246,13 +249,10 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- with .Values.deployment.resources }}
resources:
limits:
memory: {{ .Values.deployment.resources.limits.memory }}
cpu: {{ .Values.deployment.resources.limits.cpu }}
requests:
memory: {{ .Values.deployment.resources.requests.memory }}
cpu: {{ .Values.deployment.resources.requests.cpu }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- if .Values.deployment.containerSecurityContext }}
securityContext:
{{ toYaml .Values.deployment.containerSecurityContext | indent 10 }}
Expand Down Expand Up @@ -291,9 +291,11 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.rbac.serviceAccount.enabled }}
{{- if .Values.rbac.serviceAccount.name }}
serviceAccountName: {{ .Values.rbac.serviceAccount.name }}
{{- else }}
serviceAccountName: {{ template "application.name" . }}
{{- else }}
serviceAccountName: {{ template "application.name" $ }}
{{- end }}
{{- end }}
{{- end }}
5 changes: 4 additions & 1 deletion application/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ metadata:
spec:
{{- if .Values.service.type }}
type: "{{ .Values.service.type }}"
{{- end }}
{{- with .Values.service.clusterIP }}
clusterIP: {{ . }}
{{- end }}
selector:
{{ include "application.selectorLabels" . | indent 4 }}
Expand All @@ -35,4 +38,4 @@ spec:
{{- else }}
{{ toYaml .Values.service.ports | indent 4 }}
{{- end }}
{{- end }}
{{- end }}
27 changes: 27 additions & 0 deletions application/templates/vpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.vpa.enabled -}}
{{- if not (.Capabilities.APIVersions.Has "autoscaling.k8s.io/v1/VerticalPodAutoscaler") }}
{{- fail "There is no VerticalPodAutoscaler resource definition in the target cluster!" }}
{{- end }}
apiVersion: "autoscaling.k8s.io/v1"
kind: VerticalPodAutoscaler
metadata:
name: {{ template "application.name" . }}
namespace: {{ include "application.namespace" . }}
labels:
{{- include "application.labels" . | nindent 4 }}
{{- with .Values.vpa.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.vpa.annotations }}
annotations:
{{- toYaml .Values.vpa.annotations | nindent 4 }}
{{- end }}
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "application.name" . }}
resourcePolicy:
containerPolicies:
{{- toYaml .Values.vpa.containerPolicies | nindent 6 }}
{{- end }}
26 changes: 26 additions & 0 deletions application/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,29 @@ tests:
- equal:
path: spec.template.spec.containers[0].image
value: example-image:example-tag@sha256:example-digest

- it: yields empty service account name when disabled
set:
rbac.serviceAccount.enabled: false
asserts:
- notExists:
path: spec.template.spec.serviceAccountName

- it: uses service account name override when present
set:
rbac.serviceAccount.enabled: true
rbac.serviceAccount.name: example-sa
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: example-sa

- it: uses a generated service account name when not given
set:
applicationName: example-app
rbac.serviceAccount.enabled: true
rbac.serviceAccount.name: ""
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: example-app
23 changes: 22 additions & 1 deletion application/values-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ rbac:
# Service Account to use by pods
serviceAccount:
enabled: true
name: ""
name: "application"

# Additional Labels on service account
additionalLabels:
Expand Down Expand Up @@ -525,6 +525,27 @@ autoscaling:
type: Utilization
averageUtilization: 60

# autoscaling is used for vertical pod autoscaling
vpa:
# enabled is a boolean flag for enabling or disabling vpa
enabled: true
# additionalLabels defines additional labels
additionalLabels:
# key: value
# annotations defines annotations in key value pair
annotations:
# key: value
# container policies for individual containers.
# There can be at most one entry for every named container and optionally a single wildcard entry with `containerName = '*'`, which handles all containers that do not have individual policies.
containerPolicies:
- containerName: '*'
minAllowed:
cpu: 0.5
memory: 1Gi
maxAllowed:
cpu: 1
memory: 5Gi

# EndpointMonitor for IMC (https://github.com/stakater/IngressMonitorController)
endpointMonitor:
enabled: true
Expand Down
21 changes: 21 additions & 0 deletions application/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ deployment:
# values:
# - ssd

# Number of ReplicaSet versions to retain
revisionHistoryLimit: 2

# Image of the app container
image:
repository: repository/image-name
Expand Down Expand Up @@ -334,6 +337,9 @@ service:
targetPort: 8080
type: ClusterIP

# Set to 'None' will make this service headless
clusterIP:

##########################################################
# Ingress object for exposing services
##########################################################
Expand Down Expand Up @@ -610,6 +616,21 @@ autoscaling:
type: Utilization
averageUtilization: 60

##########################################################
# VPA - Vertical Pod Autoscaling
##########################################################
vpa:
# enabled is a boolean flag for enabling or disabling vpa
enabled: false
# additionalLabels defines additional labels
additionalLabels:
# key: value
# annotations defines annotations in key value pair
annotations:
# key: value
# container policies for individual containers.
containerPolicies: []

##########################################################
# EndpointMonitor for IMC
# https://github.com/stakater/IngressMonitorController
Expand Down

0 comments on commit ada6b85

Please sign in to comment.