Skip to content

Commit 000ef60

Browse files
Merge pull request #16 from karl-johan-grahn/kubernets_updates
Updates for Kubernetes, Helm, Istio, Rancher Desktop and application metrics
2 parents 9dd92f6 + f257e05 commit 000ef60

File tree

7 files changed

+180
-32
lines changed

7 files changed

+180
-32
lines changed

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Kubernetes deployment strategies
22
================================
33

4-
> In Kubernetes there is few different way to release an application, you have
4+
> In Kubernetes there are a few different ways to release an application, you have
55
to carefully choose the right strategy to make your infrastructure resilient.
66

77
- [recreate](recreate/): terminate the old version and release the new one
@@ -32,48 +32,44 @@ Before experimenting, checkout the following resources:
3232
## Getting started
3333

3434
These examples were created and tested on [Minikube](http://github.com/kubernetes/minikube)
35-
running with Kubernetes v1.10.0.
35+
running with Kubernetes v1.25.2 and [Rancher Desktop](https://rancherdesktop.io/) running
36+
with Kubernetes 1.23.6.
37+
38+
On MacOS the hypervisor VM does not have external connectivity so docker image pulls
39+
will fail. To resolve this, install another driver such as
40+
[VirtualBox](https://www.virtualbox.org/) and add `--vm-driver virtualbox`
41+
to the command to be able to pull images.
3642

3743
```
38-
$ minikube start --kubernetes-version v1.10.0 --memory 8192 --cpus 2
44+
$ minikube start --kubernetes-version v1.25.2 --memory 8192 --cpus 2
3945
```
4046

41-
4247
## Visualizing using Prometheus and Grafana
4348

4449
The following steps describe how to setup Prometheus and Grafana to visualize
4550
the progress and performance of a deployment.
4651

47-
### Install Helm
52+
### Install Helm3
4853

49-
To install Helm, follow the instructions provided on their
54+
To install Helm3, follow the instructions provided on their
5055
[website](https://github.com/kubernetes/helm/releases).
5156

52-
```
53-
$ helm init
54-
```
55-
5657
### Install Prometheus
5758

5859
```
59-
$ helm install \
60-
--namespace=monitoring \
61-
--name=prometheus \
62-
--version=7.0.0 \
63-
stable/prometheus
60+
$ helm install prometheus prometheus-community/prometheus \
61+
--create-namespace --namespace=monitoring
6462
```
6563

6664
### Install Grafana
6765

6866
```
69-
$ helm install \
67+
$ helm install grafana \
7068
--namespace=monitoring \
71-
--name=grafana \
72-
--version=1.12.0 \
7369
--set=adminUser=admin \
7470
--set=adminPassword=admin \
7571
--set=service.type=NodePort \
76-
stable/grafana
72+
grafana/grafana
7773
```
7874

7975
### Setup Grafana
@@ -95,12 +91,16 @@ Url: http://prometheus-server
9591
Access: Server
9692
```
9793

98-
Create a dashboard with a Graph. Use the following query:
94+
Create a dashboard with a Time series or import
95+
the [JSON export](grafana-dashboard.json). Use the following query:
9996

10097
```
101-
sum(rate(http_requests_total{app="my-app"}[5m])) by (version)
98+
sum(rate(http_requests_total{app="my-app"}[2m])) by (version)
10299
```
103100

101+
Since we installed Prometheus with default settings, it is using the default scrape
102+
interval of `1m` so the range cannot be lower than that.
103+
104104
To have a better overview of the version, add `{{version}}` in the legend field.
105105

106106
#### Example graph

ab-testing/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Before starting, it is recommended to know the basic concept of the
3939

4040
### Deploy Istio
4141

42-
In this example, Istio 1.0.0 is used. To install Istio, follow the
43-
[instructions](https://istio.io/docs/setup/kubernetes/helm-install/) from the
42+
In this example, Istio 1.13.4 is used. To install Istio, follow the
43+
[instructions](https://istio.io/latest/docs/setup/install/helm/) from the
4444
Istio website.
4545

4646
Automatic sidecar injection should be enabled by default. Then annotate the

app/main.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var (
3636
prometheus.CounterOpts{
3737
Name: "http_requests_total",
3838
Help: "A counter for requests to the wrapped handler.",
39-
ConstLabels: map[string]string{
39+
ConstLabels: prometheus.Labels{
4040
"version": version,
4141
},
4242
},
@@ -48,7 +48,7 @@ var (
4848
Name: "request_duration_seconds",
4949
Help: "A histogram of latencies for requests.",
5050
Buckets: []float64{.25, .5, 1, 2.5, 5, 10},
51-
ConstLabels: map[string]string{
51+
ConstLabels: prometheus.Labels{
5252
"version": version,
5353
},
5454
},
@@ -60,19 +60,18 @@ var (
6060
Name: "response_size_bytes",
6161
Help: "A histogram of response sizes for requests.",
6262
Buckets: []float64{200, 500, 900, 1500},
63-
ConstLabels: map[string]string{
63+
ConstLabels: prometheus.Labels{
6464
"version": version,
6565
},
6666
},
6767
[]string{"code", "method"},
6868
)
6969

70-
version string
70+
version = os.Getenv("VERSION")
7171
)
7272

7373
func init() {
7474
prometheus.MustRegister(inFlightGauge, counter, duration, responseSize)
75-
version = os.Getenv("VERSION")
7675
}
7776

7877
func main() {

blue-green/single-service/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ deployment "my-app-v2" successfully rolled out
3737
# traffic to the first deployment.
3838

3939
# If necessary, you can manually test one of the pod by port-forwarding it to
40-
# your local environment.
40+
# your local environment:
41+
$ kubectl port-forward <name of pod> 8080:8080
4142

4243
# Once your are ready, you can switch the traffic to the new version by patching
4344
# the service to send traffic to all pods with label version=v2.0.0

grafana-dashboard.json

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
"annotations": {
3+
"list": [
4+
{
5+
"builtIn": 1,
6+
"datasource": {
7+
"type": "grafana",
8+
"uid": "-- Grafana --"
9+
},
10+
"enable": true,
11+
"hide": true,
12+
"iconColor": "rgba(0, 211, 255, 1)",
13+
"name": "Annotations & Alerts",
14+
"target": {
15+
"limit": 100,
16+
"matchAny": false,
17+
"tags": [],
18+
"type": "dashboard"
19+
},
20+
"type": "dashboard"
21+
}
22+
]
23+
},
24+
"editable": true,
25+
"fiscalYearStartMonth": 0,
26+
"graphTooltip": 0,
27+
"id": 1,
28+
"links": [],
29+
"liveNow": false,
30+
"panels": [
31+
{
32+
"datasource": {
33+
"type": "prometheus",
34+
"uid": "VqQ98CX7z"
35+
},
36+
"description": "",
37+
"fieldConfig": {
38+
"defaults": {
39+
"color": {
40+
"mode": "palette-classic"
41+
},
42+
"custom": {
43+
"axisLabel": "",
44+
"axisPlacement": "auto",
45+
"barAlignment": 0,
46+
"drawStyle": "bars",
47+
"fillOpacity": 10,
48+
"gradientMode": "none",
49+
"hideFrom": {
50+
"legend": false,
51+
"tooltip": false,
52+
"viz": false
53+
},
54+
"lineInterpolation": "linear",
55+
"lineStyle": {
56+
"fill": "solid"
57+
},
58+
"lineWidth": 1,
59+
"pointSize": 5,
60+
"scaleDistribution": {
61+
"type": "linear"
62+
},
63+
"showPoints": "never",
64+
"spanNulls": true,
65+
"stacking": {
66+
"group": "A",
67+
"mode": "none"
68+
},
69+
"thresholdsStyle": {
70+
"mode": "off"
71+
}
72+
},
73+
"mappings": [],
74+
"thresholds": {
75+
"mode": "absolute",
76+
"steps": [
77+
{
78+
"color": "green",
79+
"value": null
80+
},
81+
{
82+
"color": "red",
83+
"value": 80
84+
}
85+
]
86+
},
87+
"unit": "short"
88+
},
89+
"overrides": []
90+
},
91+
"gridPos": {
92+
"h": 9,
93+
"w": 12,
94+
"x": 0,
95+
"y": 0
96+
},
97+
"id": 2,
98+
"options": {
99+
"legend": {
100+
"calcs": [],
101+
"displayMode": "list",
102+
"placement": "bottom"
103+
},
104+
"tooltip": {
105+
"mode": "multi",
106+
"sort": "none"
107+
}
108+
},
109+
"pluginVersion": "8.5.3",
110+
"targets": [
111+
{
112+
"datasource": {
113+
"type": "prometheus",
114+
"uid": "VqQ98CX7z"
115+
},
116+
"editorMode": "code",
117+
"exemplar": false,
118+
"expr": "sum(rate(http_requests_total{app=\"my-app\"}[2m])) by (version)",
119+
"format": "time_series",
120+
"instant": false,
121+
"interval": "",
122+
"legendFormat": "{{version}}",
123+
"range": true,
124+
"refId": "A"
125+
}
126+
],
127+
"title": "Requests Total",
128+
"type": "timeseries"
129+
}
130+
],
131+
"refresh": "",
132+
"schemaVersion": 36,
133+
"style": "dark",
134+
"tags": [],
135+
"templating": {
136+
"list": []
137+
},
138+
"time": {
139+
"from": "now-15m",
140+
"to": "now"
141+
},
142+
"timepicker": {},
143+
"timezone": "",
144+
"title": "k8s-deployment-strategies dashboard",
145+
"uid": "WM-nwCX7k",
146+
"version": 3,
147+
"weekStart": ""
148+
}

ramped/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $ kubectl rollout undo deploy my-app
5656
# subset of users
5757
$ kubectl rollout pause deploy my-app
5858

59-
# Then if you are satisfy with the result, rollout
59+
# Then if you are satisfied with the result, resume rollout
6060
$ kubectl rollout resume deploy my-app
6161
```
6262

shadow/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Before starting, it is recommended to know the basic concept of the
3737

3838
### Deploy Istio
3939

40-
In this example, Istio 1.0.0 is used. To install Istio, follow the
41-
[instructions](https://istio.io/docs/setup/kubernetes/helm-install/) from the
40+
In this example, Istio 1.13.4 is used. To install Istio, follow the
41+
[instructions](https://istio.io/latest/docs/setup/install/helm/) from the
4242
Istio website.
4343

4444
Automatic sidecar injection should be enabled by default. Then annotate the

0 commit comments

Comments
 (0)