Skip to content

Commit d930d22

Browse files
authored
fix: k8s 1.22 do cluster deployment (#748)
1 parent 1dfb6f4 commit d930d22

7 files changed

Lines changed: 63 additions & 33 deletions

File tree

.do/Makefile

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,32 +102,33 @@ remove_codacy: set_cluster_context
102102
kubectl delete secret -n ${NAMESPACE} docker-credentials
103103

104104
.PHONY: deploy_monitoring
105-
deploy_monitoring: set_cluster_context
106-
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml"
107-
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml"
108-
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml"
109-
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml"
110-
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml"
111-
kubectl apply -f "https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.38/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml"
105+
deploy_monitoring: #set_cluster_context
106+
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml
107+
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml
108+
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
109+
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml
110+
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml
111+
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
112+
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
113+
kubectl apply --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.58.0/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml
112114

113115
helm repo add loki https://grafana.github.io/loki/charts
116+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
117+
helm repo update
114118
-kubectl create namespace monitoring
115119

116120
helm upgrade --install --atomic --timeout 600s loki loki/loki \
117-
--version 0.28.1 --namespace monitoring --values ../docs/values-files/values-loki.yaml
121+
--version 2.1.1 --namespace monitoring --values ../docs/values-files/values-loki.yaml
118122

119123
helm upgrade --install --atomic --timeout 600s promtail loki/promtail \
120-
--version 0.22.2 --namespace monitoring --values ../docs/values-files/values-promtail.yaml
124+
--version 2.0.2 --namespace monitoring --values values-promtail.yaml
121125

122126
@sed -i "s#<--- slack-api-url --->#$$SLACK_API_URL_ALERTS_SELFHOSTED#g;" values-prometheus-operator.yaml
123127
@sed -i "s/<--- slack-channel --->/$$SLACK_ALERTS_SELFHOSTED_CHANNEL/g;" values-prometheus-operator.yaml
124128
@sed -i "s#<--- grafana url --->#${GRAFANA_URL}#g; s#https://##g" ../docs/values-files/values-prometheus-operator.yaml
125129

126-
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
127-
helm repo update
128-
129-
helm upgrade --install --atomic --timeout 600s monitoring prometheus-community/kube-prometheus-stack \
130-
--version 9.4.3 --namespace monitoring --values ../docs/values-files/values-prometheus-operator.yaml --values values-prometheus-operator.yaml\
130+
helm upgrade --install --atomic --timeout 1600s monitoring prometheus-community/kube-prometheus-stack \
131+
--version 39.1.0 --namespace monitoring --values ../docs/values-files/values-prometheus-operator.yaml --values values-prometheus-operator.yaml\
131132
--set grafana.adminPassword=$$GRAFANA_ADMIN_PASSWORD \
132133
--set grafana.ingress.hosts='{grafana.k8s.dev.codacy.org}' \
133134
--set alertmanager.ingress.hosts='{alerts.k8s.dev.codacy.org}' \

.do/k8s-cluster/Makefile

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ TF_PARALLELISM ?= 30
55
TF ?= $(TF_EXTRA_OPTS) terraform
66
WORKSPACE ?= ${DO_TF_WORKSPACE}
77
VARS_FILE ?= deploy.tfvars
8-
NGINX_INGRESS_VERSION ?= 2.16.0
9-
CERT_MANAGER_VERSION ?= v0.15.1
8+
NGINX_INGRESS_VERSION ?= 4.2.0
9+
CERT_MANAGER_VERSION ?= v1.9.1
1010
K8S_VERSION ?= 1.22
1111
DO_K8S_SLUG ?= $(shell doctl kubernetes options versions | grep $(K8S_VERSION) | awk '{print $$1}')
1212
NODE_TYPE ?= s-8vcpu-32gb
@@ -57,32 +57,19 @@ install_nginx:
5757
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
5858
helm repo add stable https://charts.helm.sh/stable
5959
helm repo update
60-
6160
helm upgrade --install nginx-ingress --version ${NGINX_INGRESS_VERSION} --namespace kube-system ingress-nginx/ingress-nginx \
62-
-f values-nginx.yaml
61+
-f values/values-nginx.yaml
6362

6463
.PHONY: install_certmanager
6564
install_certmanager:
6665
helm repo add jetstack https://charts.jetstack.io
6766
helm repo update
68-
# Actually install cert-manager
69-
wget https://docs.codacy.com/chart/values-files/values-cert-manager.yaml >/dev/null 2>&1
70-
ytool -f "values-cert-manager.yaml" -s global.leaderElection.namespace "kube-system" -e
71-
ytool -f "values-cert-manager.yaml" -s ingressShim.defaultIssuerKind "ClusterIssuer" -e
7267
helm upgrade --install --version ${CERT_MANAGER_VERSION} codacy-cert-manager jetstack/cert-manager \
7368
--namespace kube-system \
74-
--values values-cert-manager.yaml \
69+
--values values/values-cert-manager.yaml \
7570
--set installCRDs=true
76-
7771
kubectl label namespace kube-system certmanager.k8s.io/disable-validation="true" --overwrite
78-
79-
# Fetch and patch issuer-letsencrypt.yaml Issuer
80-
wget https://docs.codacy.com/chart/values-files/issuer-letsencrypt.yaml >/dev/null 2>&1
81-
ytool -f "issuer-letsencrypt.yaml" -s spec.acme.email "reliability@codacy.com" -e
82-
ytool -f "issuer-letsencrypt.yaml" -s metadata.name "letsencrypt-codacy" -e
83-
ytool -f "issuer-letsencrypt.yaml" -s metadata.namespace "kube-system" -e
84-
ytool -f "issuer-letsencrypt.yaml" -s kind "ClusterIssuer" -e
85-
kubectl apply --namespace kube-system -f issuer-letsencrypt.yaml
72+
kubectl apply --namespace kube-system -f values/issuer-letsencrypt.yaml
8673

8774
.PHONY: destroy_cluster
8875
destroy_cluster: setup_vars create_terraformrc set_cluster_context tf_init tf_validate
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: ClusterIssuer
3+
metadata:
4+
name: letsencrypt-codacy
5+
namespace: kube-system
6+
spec:
7+
acme:
8+
server: https://acme-v02.api.letsencrypt.org/directory
9+
email: reliability@codacy.com
10+
privateKeySecretRef:
11+
name: letsencrypt
12+
solvers:
13+
- http01:
14+
ingress:
15+
class: nginx
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
webhook:
2+
enabled: true
3+
ingressShim:
4+
defaultIssuerName: letsencrypt-codacy
5+
defaultIssuerKind: ClusterIssuer
6+
defaultIssuerGroup: cert-manager.io
7+
global:
8+
leaderElection:
9+
namespace: kube-system

.do/values-prometheus-operator.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
defaultRules:
22
create: false # disable the default alertmanager rules that monitor the cluster
33

4+
prometheusOperator:
5+
tls:
6+
enabled: false
7+
admissionWebhooks:
8+
enabled: false
9+
410
## Configuration for alertmanager
511
## based off of: https://medium.com/faun/trying-prometheus-operator-with-helm-minikube-b617a2dccfa3
612
## and: https://awesome-prometheus-alerts.grep.to/alertmanager
@@ -38,4 +44,4 @@ alertmanager:
3844
*Details:*
3945
{{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
4046
{{ end }}
41-
{{ end }}
47+
{{ end }}

.do/values-promtail.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
loki:
2+
serviceName: loki
3+
4+
config:
5+
client:
6+
batchwait: 1s
7+
batchsize: 10240
8+
timeout: 20s
9+
backoff_config:
10+
min_period: 2s
11+
max_period: 20s
12+
max_retries: 5

0 commit comments

Comments
 (0)