Skip to content

Commit

Permalink
Argo Rollout
Browse files Browse the repository at this point in the history
  • Loading branch information
vfarcic committed Oct 4, 2020
1 parent 94203e3 commit 25723d2
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 94 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.idea
/*.iml
/public
/devops-toolkit
/devops-toolkit
/env
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM nginx:stable-alpine
# FROM bitnami/nginx

RUN mv /usr/share/nginx/html/index.html /usr/share/nginx/html/old-index.html
COPY public /usr/share/nginx/html
# COPY public /app
EXPOSE 80
15 changes: 0 additions & 15 deletions argo/application-production.yaml

This file was deleted.

15 changes: 0 additions & 15 deletions argo/application.yaml

This file was deleted.

Binary file modified content/.DS_Store
Binary file not shown.
33 changes: 15 additions & 18 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{- if .Values.knativeDeploy }}
{{- if or .Values.knativeDeploy .Values.rollout.deploy }}
{{- else }}
---

apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -11,37 +13,32 @@ spec:
selector:
matchLabels:
app: {{ template "fullname" . }}
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ template "fullname" . }}
{{- if .Values.podAnnotations }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.internalPort }}
- containerPort: 80
livenessProbe:
httpGet:
path: {{ .Values.probePath }}
port: {{ .Values.service.internalPort }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
path: /
port: 80
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
httpGet:
path: {{ .Values.probePath }}
port: {{ .Values.service.internalPort }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
path: /
port: 80
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
24 changes: 24 additions & 0 deletions helm/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.hpa }}
---

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "fullname" . }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
app: {{ template "fullname" . }}
spec:
minReplicas: 2
maxReplicas: 6
scaleTargetRef:
{{- if .Values.rollout.deploy }}
apiVersion: argoproj.io/v1alpha1
kind: Rollout
{{- else }}
apiVersion: apps/v1
kind: Deployment
{{- end }}
name: {{ template "fullname" . }}
targetCPUUtilizationPercentage: 80
{{- end }}
8 changes: 6 additions & 2 deletions helm/templates/ing.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---

{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }}
apiVersion: networking.k8s.io/v1beta1
{{ else }}
apiVersion: extensions/v1beta1
{{ end -}}
kind: Ingress
metadata:
name: {{ template "fullname" . }}
Expand All @@ -8,12 +13,11 @@ metadata:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
annotations:
kubernetes.io/ingress.class: "nginx"
certmanager.k8s.io/issuer: "letsencrypt-prod"
spec:
rules:
- http:
paths:
- backend:
serviceName: {{ .Values.service.name }}
serviceName: {{ template "fullname" . }}
servicePort: 80
host: {{ .Values.ingress.host }}
24 changes: 11 additions & 13 deletions helm/templates/ksvc.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---

{{- if .Values.knativeDeploy }}
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
{{- if .Values.service.name }}
name: {{ .Values.service.name }}
{{- else }}
name: {{ template "fullname" . }}
{{- end }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
Expand All @@ -19,17 +17,17 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
livenessProbe:
httpGet:
path: {{ .Values.probePath }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
path: /
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
httpGet:
path: {{ .Values.probePath }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
path: /
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
{{ toYaml .Values.resources | indent 14 }}
{{- end }}
70 changes: 70 additions & 0 deletions helm/templates/rollout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{{- if .Values.rollout.deploy }}
---

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: {{ template "fullname" . }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
app: {{ template "fullname" . }}
spec:
selector:
matchLabels:
app: {{ template "fullname" . }}
template:
metadata:
labels:
app: {{ template "fullname" . }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
httpGet:
path: /
port: 80
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
{{ toYaml .Values.resources | indent 12 }}
strategy:
canary:
canaryService: {{ template "fullname" . }}-canary
stableService: {{ template "fullname" . }}
trafficRouting:
nginx:
stableIngress: {{ template "fullname" . }}
steps:
{{ toYaml .Values.rollout.steps | indent 6 }}

---

apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}-canary
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
selector:
app: {{ template "fullname" . }}
{{- end }}
16 changes: 5 additions & 11 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
---

{{- if .Values.knativeDeploy }}
{{- else }}
apiVersion: v1
kind: Service
metadata:
{{- if .Values.service.name }}
name: {{ .Values.service.name }}
{{- else }}
name: {{ template "fullname" . }}
{{- end }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
type: ClusterIP
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
- port: 80
targetPort: 80
protocol: TCP
name: http
selector:
Expand Down
29 changes: 13 additions & 16 deletions helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
replicaCount: 1
image:
repository: vfarcic/devops-toolkit-series
tag: latest
pullPolicy: IfNotPresent
knativeDeploy: false
ingress:
host: devopstoolkitseries.com
service:
name: devops-toolkit
type: ClusterIP
externalPort: 80
internalPort: 80
annotations:
fabric8.io/expose: "true"
fabric8.io/ingress.annotations: "kubernetes.io/ingress.class: nginx"
resources:
limits:
cpu: 100m
memory: 256Mi
requests:
cpu: 80m
memory: 128Mi
probePath: /
livenessProbe:
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
hpa: false
knativeDeploy: false
rollout:
deploy: false
steps:
- setWeight: 20
- pause: {duration: 10}
- setWeight: 40
- pause: {duration: 10}
- setWeight: 60
- pause: {duration: 10}
- setWeight: 80
- pause: {duration: 10}
3 changes: 2 additions & 1 deletion k8s/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ spec:
memory: 256Mi
requests:
cpu: 80m
memory: 128Mi
memory: 128Mi

12 changes: 12 additions & 0 deletions rollout/values-pause-x2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
hpa: true
rollout:
deploy: true
steps:
- setWeight: 20
- pause: {}
- setWeight: 40
- pause: {}
- setWeight: 60
- pause: {duration: 10}
- setWeight: 80
- pause: {duration: 10}

0 comments on commit 25723d2

Please sign in to comment.