mirror of
https://github.com/marcel-dempers/docker-development-youtube-series.git
synced 2025-06-06 17:01:30 +00:00
Merge branch 'master' into terraform-aws-eks
This commit is contained in:
commit
01ac5a8659
37
.github/workflows/docker._yaml
vendored
Normal file
37
.github/workflows/docker._yaml
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
###########################################################
|
||||
# Rename the file extension to ".yaml" (remove "_") to enable
|
||||
###########################################################
|
||||
|
||||
name: Docker Series Builds
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: docker login
|
||||
env:
|
||||
DOCKER_USER: ${{ secrets.DOCKER_USER }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
run: |
|
||||
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
|
||||
- name: docker build csharp
|
||||
run: |
|
||||
docker build ./c# -t aimvector/csharp:1.0.0
|
||||
- name: docker build nodejs
|
||||
run: |
|
||||
docker build ./nodejs -t aimvector/nodejs:1.0.0
|
||||
- name: docker build python
|
||||
run: |
|
||||
docker build ./python -t aimvector/python:1.0.0
|
||||
- name: docker build golang
|
||||
run: |
|
||||
docker build ./golang -t aimvector/golang:1.0.0
|
||||
- name: docker push
|
||||
run: |
|
||||
docker push aimvector/csharp:1.0.0
|
||||
docker push aimvector/nodejs:1.0.0
|
||||
docker push aimvector/golang:1.0.0
|
||||
docker push aimvector/python:1.0.0
|
34
.github/workflows/docker.yml
vendored
34
.github/workflows/docker.yml
vendored
@ -1,34 +0,0 @@
|
||||
# name: Docker Series Builds
|
||||
|
||||
# #uncomment to enable push trigger
|
||||
# #on: [push]
|
||||
|
||||
# jobs:
|
||||
# build:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - name: docker login
|
||||
# env:
|
||||
# DOCKER_USER: ${{ secrets.DOCKER_USER }}
|
||||
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
# run: |
|
||||
# docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
|
||||
# - name: docker build csharp
|
||||
# run: |
|
||||
# docker build ./c# -t aimvector/csharp:1.0.0
|
||||
# - name: docker build nodejs
|
||||
# run: |
|
||||
# docker build ./nodejs -t aimvector/nodejs:1.0.0
|
||||
# - name: docker build python
|
||||
# run: |
|
||||
# docker build ./python -t aimvector/python:1.0.0
|
||||
# - name: docker build golang
|
||||
# run: |
|
||||
# docker build ./golang -t aimvector/golang:1.0.0
|
||||
# - name: docker push
|
||||
# run: |
|
||||
# docker push aimvector/csharp:1.0.0
|
||||
# docker push aimvector/nodejs:1.0.0
|
||||
# docker push aimvector/golang:1.0.0
|
||||
# docker push aimvector/python:1.0.0
|
22
kubernetes/autoscaling/components/application/app.go
Normal file
22
kubernetes/autoscaling/components/application/app.go
Normal file
@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main(){
|
||||
http.HandleFunc("/", useCPU)
|
||||
http.ListenAndServe(":80", nil)
|
||||
}
|
||||
|
||||
func useCPU(w http.ResponseWriter, r *http.Request) {
|
||||
count := 1
|
||||
|
||||
for i := 1; i <= 1000000; i++ {
|
||||
count = i
|
||||
}
|
||||
|
||||
fmt.Printf("count: %d", count)
|
||||
w.Write([]byte(string(count)))
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: application-cpu
|
||||
labels:
|
||||
app: application-cpu
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: application-cpu
|
||||
ports:
|
||||
- protocol: TCP
|
||||
name: http
|
||||
port: 80
|
||||
targetPort: 80
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: application-cpu
|
||||
labels:
|
||||
app: application-cpu
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: application-cpu
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxSurge: 1
|
||||
maxUnavailable: 0
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: application-cpu
|
||||
spec:
|
||||
containers:
|
||||
- name: application-cpu
|
||||
image: aimvector/application-cpu:v1.0.2
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 80
|
||||
resources:
|
||||
requests:
|
||||
memory: "50Mi"
|
||||
cpu: "500m"
|
||||
limits:
|
||||
memory: "500Mi"
|
||||
cpu: "2000m"
|
15
kubernetes/autoscaling/components/application/dockerfile
Normal file
15
kubernetes/autoscaling/components/application/dockerfile
Normal file
@ -0,0 +1,15 @@
|
||||
FROM golang:1.14-alpine as build
|
||||
|
||||
RUN apk add --no-cache git curl
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY app.go /src
|
||||
|
||||
RUN go build app.go
|
||||
|
||||
FROM alpine as runtime
|
||||
|
||||
COPY --from=build /src/app /app/app
|
||||
|
||||
CMD [ "/app/app" ]
|
@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: traffic-generator
|
||||
spec:
|
||||
containers:
|
||||
- name: alpine
|
||||
image: alpine
|
||||
args:
|
||||
- sleep
|
||||
- "100000000"
|
@ -0,0 +1,153 @@
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: system:aggregated-metrics-reader
|
||||
labels:
|
||||
rbac.authorization.k8s.io/aggregate-to-view: "true"
|
||||
rbac.authorization.k8s.io/aggregate-to-edit: "true"
|
||||
rbac.authorization.k8s.io/aggregate-to-admin: "true"
|
||||
rules:
|
||||
- apiGroups: ["metrics.k8s.io"]
|
||||
resources: ["pods", "nodes"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: metrics-server:system:auth-delegator
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: system:auth-delegator
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: metrics-server
|
||||
namespace: kube-system
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: metrics-server-auth-reader
|
||||
namespace: kube-system
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: extension-apiserver-authentication-reader
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: metrics-server
|
||||
namespace: kube-system
|
||||
---
|
||||
apiVersion: apiregistration.k8s.io/v1beta1
|
||||
kind: APIService
|
||||
metadata:
|
||||
name: v1beta1.metrics.k8s.io
|
||||
spec:
|
||||
service:
|
||||
name: metrics-server
|
||||
namespace: kube-system
|
||||
group: metrics.k8s.io
|
||||
version: v1beta1
|
||||
insecureSkipTLSVerify: true
|
||||
groupPriorityMinimum: 100
|
||||
versionPriority: 100
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: metrics-server
|
||||
namespace: kube-system
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: metrics-server
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-app: metrics-server
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s-app: metrics-server
|
||||
template:
|
||||
metadata:
|
||||
name: metrics-server
|
||||
labels:
|
||||
k8s-app: metrics-server
|
||||
spec:
|
||||
serviceAccountName: metrics-server
|
||||
volumes:
|
||||
# mount in tmp so we can safely use from-scratch images and/or read-only containers
|
||||
- name: tmp-dir
|
||||
emptyDir: {}
|
||||
containers:
|
||||
- name: metrics-server
|
||||
image: k8s.gcr.io/metrics-server/metrics-server:v0.3.7
|
||||
imagePullPolicy: IfNotPresent
|
||||
args:
|
||||
- --cert-dir=/tmp
|
||||
- --secure-port=4443
|
||||
#- --kubelet-insecure-tls
|
||||
#- --kubelet-preferred-address-types="InternalIP"
|
||||
ports:
|
||||
- name: main-port
|
||||
containerPort: 4443
|
||||
protocol: TCP
|
||||
securityContext:
|
||||
readOnlyRootFilesystem: true
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
volumeMounts:
|
||||
- name: tmp-dir
|
||||
mountPath: /tmp
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
kubernetes.io/arch: "amd64"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: metrics-server
|
||||
namespace: kube-system
|
||||
labels:
|
||||
kubernetes.io/name: "Metrics-server"
|
||||
kubernetes.io/cluster-service: "true"
|
||||
spec:
|
||||
selector:
|
||||
k8s-app: metrics-server
|
||||
ports:
|
||||
- port: 443
|
||||
protocol: TCP
|
||||
targetPort: main-port
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: system:metrics-server
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- pods
|
||||
- nodes
|
||||
- nodes/stats
|
||||
- namespaces
|
||||
- configmaps
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: system:metrics-server
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: system:metrics-server
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: metrics-server
|
||||
namespace: kube-system
|
172
kubernetes/autoscaling/readme.md
Normal file
172
kubernetes/autoscaling/readme.md
Normal file
@ -0,0 +1,172 @@
|
||||
# Kubernetes Autoscaling Guide
|
||||
|
||||
## Cluster Autoscaling
|
||||
|
||||
Cluster autoscaler allows us to scale cluster nodes when they become full <br/>
|
||||
I would recommend to learn about scaling your cluster nodes before scaling pods. <br/>
|
||||
Video [here](https://youtu.be/jM36M39MA3I)
|
||||
|
||||
## Horizontal Pod Autoscaling
|
||||
|
||||
HPA allows us to scale pods when their resource utilisation goes over a threshold <br/>
|
||||
|
||||
## Requirements
|
||||
|
||||
### A Cluster
|
||||
|
||||
* For both autoscaling guides, we'll need a cluster. <br/>
|
||||
* For `Cluster Autoscaler` You need a cloud based cluster that supports the cluster autoscaler <br/>
|
||||
* For `HPA` We'll use [kind](http://kind.sigs.k8s.io/)
|
||||
|
||||
### Cluster Autoscaling - Creating an AKS Cluster
|
||||
|
||||
```
|
||||
# azure example
|
||||
|
||||
NAME=aks-getting-started
|
||||
RESOURCEGROUP=aks-getting-started
|
||||
SERVICE_PRINCIPAL=
|
||||
SERVICE_PRINCIPAL_SECRET=
|
||||
|
||||
az aks create -n $NAME \
|
||||
--resource-group $RESOURCEGROUP \
|
||||
--location australiaeast \
|
||||
--kubernetes-version 1.16.10 \
|
||||
--nodepool-name default \
|
||||
--node-count 1 \
|
||||
--node-vm-size Standard_F4s_v2 \
|
||||
--node-osdisk-size 250 \
|
||||
--service-principal $SERVICE_PRINCIPAL \
|
||||
--client-secret $SERVICE_PRINCIPAL_SECRET \
|
||||
--output none \
|
||||
--enable-cluster-autoscaler \
|
||||
--min-count 1 \
|
||||
--max-count 5
|
||||
```
|
||||
|
||||
### Horizontal Pod Autocaling - Creating a Kind Cluster
|
||||
|
||||
My Node has 6 CPU cores for this demo <br/>
|
||||
|
||||
```
|
||||
kind create cluster --name hpa --image kindest/node:v1.18.4
|
||||
```
|
||||
|
||||
### Metric Server
|
||||
|
||||
* For `Cluster Autoscaler` - On cloud-based clusters, Metric server may already be installed. <br/>
|
||||
* For `HPA` - We're using kind
|
||||
|
||||
[Metric Server](https://github.com/kubernetes-sigs/metrics-server) provides container resource metrics for use in autoscaling pipelines <br/>
|
||||
|
||||
Because I run K8s `1.18` in `kind`, the Metric Server version i need is `0.3.7` <br/>
|
||||
We will need to deploy Metric Server [0.3.7](https://github.com/kubernetes-sigs/metrics-server/releases/tag/v0.3.7) <br/>
|
||||
I used `components.yaml`from the release page link above. <br/>
|
||||
|
||||
<b>Important Note</b> : For Demo clusters (like `kind`), you will need to disable TLS <br/>
|
||||
You can disable TLS by adding the following to the metrics-server container args <br/>
|
||||
|
||||
<b>For production, make sure you remove the following :</b> <br/>
|
||||
|
||||
```
|
||||
- --kubelet-insecure-tls
|
||||
- --kubelet-preferred-address-types="InternalIP"
|
||||
|
||||
```
|
||||
|
||||
Deployment: <br/>
|
||||
|
||||
|
||||
```
|
||||
cd kubernetes\autoscaling
|
||||
kubectl -n kube-system apply -f .\components\metric-server\metricserver-0.3.7.yaml
|
||||
|
||||
#test
|
||||
kubectl -n kube-system get pods
|
||||
|
||||
#note: wait for metrics to populate!
|
||||
kubectl top nodes
|
||||
|
||||
```
|
||||
|
||||
## Example Application
|
||||
|
||||
For all autoscaling guides, we'll need a simple app, that generates some CPU load <br/>
|
||||
|
||||
* Build the app
|
||||
* Push it to a registry
|
||||
* Ensure resource requirements are set
|
||||
* Deploy it to Kubernetes
|
||||
* Ensure metrics are visible for the app
|
||||
|
||||
```
|
||||
# build
|
||||
|
||||
cd kubernetes\autoscaling\components\application
|
||||
docker build . -t aimvector/application-cpu:v1.0.0
|
||||
|
||||
# push
|
||||
docker push aimvector/application-cpu:v1.0.0
|
||||
|
||||
# resource requirements
|
||||
resources:
|
||||
requests:
|
||||
memory: "50Mi"
|
||||
cpu: "500m"
|
||||
limits:
|
||||
memory: "500Mi"
|
||||
cpu: "2000m"
|
||||
|
||||
# deploy
|
||||
kubectl apply -f deployment.yaml
|
||||
|
||||
# metrics
|
||||
kubectl top pods
|
||||
|
||||
```
|
||||
|
||||
## Cluster Autoscaler
|
||||
|
||||
For cluster autoscaling, you should be able to scale the pods manually and watch the cluster scale. </br>
|
||||
Cluster autoscaling stops here. </br>
|
||||
For Pod Autoscaling (HPA), continue</br>
|
||||
|
||||
## Generate some traffic
|
||||
|
||||
Let's deploy a simple traffic generator pod
|
||||
|
||||
```
|
||||
cd kubernetes\autoscaling\components\application
|
||||
kubectl apply -f .\traffic-generator.yaml
|
||||
|
||||
# get a terminal to the traffic-generator
|
||||
kubectl exec -it traffic-generator sh
|
||||
|
||||
# install wrk
|
||||
apk add --no-cache wrk
|
||||
|
||||
# simulate some load
|
||||
wrk -c 5 -t 5 -d 99999 -H "Connection: Close" http://application-cpu
|
||||
|
||||
#you can scale to pods manually and see roughly 6-7 pods will satisfy resource requests.
|
||||
kubectl scale deploy/application-cpu --replicas 2
|
||||
```
|
||||
|
||||
## Deploy an autoscaler
|
||||
|
||||
```
|
||||
# scale the deployment back down to 2
|
||||
kubectl scale deploy/application-cpu --replicas 2
|
||||
|
||||
# deploy the autoscaler
|
||||
kubectl autoscale deploy/application-cpu --cpu-percent=95 --min=1 --max=10
|
||||
|
||||
# pods should scale to roughly 6-7 to match criteria of 95% of resource requests
|
||||
|
||||
kubectl get pods
|
||||
kubectl top pods
|
||||
kubectl get hpa/application-cpu -owide
|
||||
|
||||
kubectl describe hpa/application-cpu
|
||||
|
||||
```
|
@ -43,15 +43,17 @@ spec:
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
cpu: "500m"
|
||||
volumeMounts:
|
||||
- name: secret-volume
|
||||
mountPath: /secrets/
|
||||
- name: config-volume
|
||||
mountPath: /configs/
|
||||
volumes:
|
||||
- name: secret-volume
|
||||
secret:
|
||||
secretName: mysecret
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: example-config #name of our configmap object
|
||||
#NOTE: comment out `volumeMounts` section for configmap and\or secret guide
|
||||
# volumeMounts:
|
||||
# - name: secret-volume
|
||||
# mountPath: /secrets/
|
||||
# - name: config-volume
|
||||
# mountPath: /configs/
|
||||
#NOTE: comment out `volumes` section for configmap and\or secret guide
|
||||
# volumes:
|
||||
# - name: secret-volume
|
||||
# secret:
|
||||
# secretName: mysecret
|
||||
# - name: config-volume
|
||||
# configMap:
|
||||
# name: example-config #name of our configmap object
|
||||
|
78
messaging/rabbitmq/applications/consumer/consumer.go
Normal file
78
messaging/rabbitmq/applications/consumer/consumer.go
Normal file
@ -0,0 +1,78 @@
|
||||
package main
|
||||
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/streadway/amqp"
|
||||
"os"
|
||||
)
|
||||
|
||||
var rabbit_host = os.Getenv("RABBIT_HOST")
|
||||
var rabbit_port = os.Getenv("RABBIT_PORT")
|
||||
var rabbit_user = os.Getenv("RABBIT_USERNAME")
|
||||
var rabbit_password = os.Getenv("RABBIT_PASSWORD")
|
||||
|
||||
func main() {
|
||||
consume()
|
||||
}
|
||||
|
||||
func consume() {
|
||||
|
||||
conn, err := amqp.Dial("amqp://" + rabbit_user + ":" +rabbit_password + "@" + rabbit_host + ":" + rabbit_port +"/")
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%s: %s", "Failed to connect to RabbitMQ", err)
|
||||
}
|
||||
|
||||
ch, err := conn.Channel()
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%s: %s", "Failed to open a channel", err)
|
||||
}
|
||||
|
||||
q, err := ch.QueueDeclare(
|
||||
"publisher", // name
|
||||
true, // durable
|
||||
false, // delete when unused
|
||||
false, // exclusive
|
||||
false, // no-wait
|
||||
nil, // arguments
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%s: %s", "Failed to declare a queue", err)
|
||||
}
|
||||
|
||||
fmt.Println("Channel and Queue established")
|
||||
|
||||
defer conn.Close()
|
||||
defer ch.Close()
|
||||
|
||||
msgs, err := ch.Consume(
|
||||
q.Name, // queue
|
||||
"", // consumer
|
||||
false, // auto-ack
|
||||
false, // exclusive
|
||||
false, // no-local
|
||||
false, // no-wait
|
||||
nil, // args
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%s: %s", "Failed to register consumer", err)
|
||||
}
|
||||
|
||||
forever := make(chan bool)
|
||||
|
||||
go func() {
|
||||
for d := range msgs {
|
||||
log.Printf("Received a message: %s", d.Body)
|
||||
|
||||
d.Ack(false)
|
||||
}
|
||||
}()
|
||||
|
||||
fmt.Println("Running...")
|
||||
<-forever
|
||||
}
|
19
messaging/rabbitmq/applications/consumer/dockerfile
Normal file
19
messaging/rabbitmq/applications/consumer/dockerfile
Normal file
@ -0,0 +1,19 @@
|
||||
FROM golang:1.14-alpine as build
|
||||
|
||||
RUN apk add --no-cache git
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
RUN go get github.com/sirupsen/logrus
|
||||
RUN go get github.com/streadway/amqp
|
||||
|
||||
COPY consumer.go /src
|
||||
|
||||
RUN go build consumer.go
|
||||
|
||||
|
||||
FROM alpine as runtime
|
||||
|
||||
COPY --from=build /src/consumer /app/consumer
|
||||
|
||||
CMD [ "/app/consumer" ]
|
62
messaging/rabbitmq/applications/publisher/deployment.yaml
Normal file
62
messaging/rabbitmq/applications/publisher/deployment.yaml
Normal file
@ -0,0 +1,62 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: rabbitmq-publisher
|
||||
type: Opaque
|
||||
data:
|
||||
RABBIT_USERNAME: Z3Vlc3Q=
|
||||
RABBIT_PASSWORD: Z3Vlc3Q=
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: rabbitmq-publisher
|
||||
labels:
|
||||
app: rabbitmq-publisher
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: rabbitmq-publisher
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: rabbitmq-publisher
|
||||
spec:
|
||||
containers:
|
||||
- name: rabbitmq-publisher
|
||||
image: aimvector/rabbitmq-publisher:v1.0.0
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 80
|
||||
env:
|
||||
- name: RABBIT_HOST
|
||||
value: "rabbitmq-0.rabbitmq.rabbits.svc.cluster.local"
|
||||
- name: RABBIT_PORT
|
||||
value: "5672"
|
||||
- name: RABBIT_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: rabbitmq-publisher
|
||||
key: RABBIT_USERNAME
|
||||
- name: RABBIT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: rabbitmq-publisher
|
||||
key: RABBIT_PASSWORD
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: rabbitmq-publisher
|
||||
labels:
|
||||
app: rabbitmq-publisher
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
selector:
|
||||
app: rabbitmq-publisher
|
||||
ports:
|
||||
- protocol: TCP
|
||||
name: http
|
||||
port: 80
|
||||
targetPort: 80
|
19
messaging/rabbitmq/applications/publisher/dockerfile
Normal file
19
messaging/rabbitmq/applications/publisher/dockerfile
Normal file
@ -0,0 +1,19 @@
|
||||
FROM golang:1.14-alpine as build
|
||||
|
||||
RUN apk add --no-cache git
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
RUN go get github.com/julienschmidt/httprouter
|
||||
RUN go get github.com/sirupsen/logrus
|
||||
RUN go get github.com/streadway/amqp
|
||||
|
||||
COPY publisher.go /src
|
||||
|
||||
RUN go build publisher.go
|
||||
|
||||
FROM alpine as runtime
|
||||
|
||||
COPY --from=build /src/publisher /app/publisher
|
||||
|
||||
CMD [ "/app/publisher" ]
|
78
messaging/rabbitmq/applications/publisher/publisher.go
Normal file
78
messaging/rabbitmq/applications/publisher/publisher.go
Normal file
@ -0,0 +1,78 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/streadway/amqp"
|
||||
"os"
|
||||
)
|
||||
|
||||
var rabbit_host = os.Getenv("RABBIT_HOST")
|
||||
var rabbit_port = os.Getenv("RABBIT_PORT")
|
||||
var rabbit_user = os.Getenv("RABBIT_USERNAME")
|
||||
var rabbit_password = os.Getenv("RABBIT_PASSWORD")
|
||||
|
||||
func main() {
|
||||
|
||||
router := httprouter.New()
|
||||
|
||||
router.POST("/publish/:message", func(w http.ResponseWriter, r *http.Request, p httprouter.Params){
|
||||
submit(w,r,p)
|
||||
})
|
||||
|
||||
fmt.Println("Running...")
|
||||
log.Fatal(http.ListenAndServe(":80", router))
|
||||
}
|
||||
|
||||
func submit(writer http.ResponseWriter, request *http.Request, p httprouter.Params) {
|
||||
message := p.ByName("message")
|
||||
|
||||
fmt.Println("Received message: " + message)
|
||||
|
||||
conn, err := amqp.Dial("amqp://" + rabbit_user + ":" +rabbit_password + "@" + rabbit_host + ":" + rabbit_port +"/")
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%s: %s", "Failed to connect to RabbitMQ", err)
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
|
||||
ch, err := conn.Channel()
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%s: %s", "Failed to open a channel", err)
|
||||
}
|
||||
|
||||
defer ch.Close()
|
||||
|
||||
q, err := ch.QueueDeclare(
|
||||
"publisher", // name
|
||||
true, // durable
|
||||
false, // delete when unused
|
||||
false, // exclusive
|
||||
false, // no-wait
|
||||
nil, // arguments
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%s: %s", "Failed to declare a queue", err)
|
||||
}
|
||||
|
||||
err = ch.Publish(
|
||||
"", // exchange
|
||||
q.Name, // routing key
|
||||
false, // mandatory
|
||||
false, // immediate
|
||||
amqp.Publishing {
|
||||
ContentType: "text/plain",
|
||||
Body: []byte(message),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%s: %s", "Failed to publish a message", err)
|
||||
}
|
||||
|
||||
fmt.Println("publish success!")
|
||||
}
|
7
messaging/rabbitmq/config/rabbit-1/rabbitmq.conf
Normal file
7
messaging/rabbitmq/config/rabbit-1/rabbitmq.conf
Normal file
@ -0,0 +1,7 @@
|
||||
loopback_users.guest = false
|
||||
listeners.tcp.default = 5672
|
||||
|
||||
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
|
||||
cluster_formation.classic_config.nodes.1 = rabbit@rabbit-1
|
||||
cluster_formation.classic_config.nodes.2 = rabbit@rabbit-2
|
||||
cluster_formation.classic_config.nodes.3 = rabbit@rabbit-3
|
7
messaging/rabbitmq/config/rabbit-2/rabbitmq.conf
Normal file
7
messaging/rabbitmq/config/rabbit-2/rabbitmq.conf
Normal file
@ -0,0 +1,7 @@
|
||||
loopback_users.guest = false
|
||||
listeners.tcp.default = 5672
|
||||
|
||||
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
|
||||
cluster_formation.classic_config.nodes.1 = rabbit@rabbit-1
|
||||
cluster_formation.classic_config.nodes.2 = rabbit@rabbit-2
|
||||
cluster_formation.classic_config.nodes.3 = rabbit@rabbit-3
|
7
messaging/rabbitmq/config/rabbit-3/rabbitmq.conf
Normal file
7
messaging/rabbitmq/config/rabbit-3/rabbitmq.conf
Normal file
@ -0,0 +1,7 @@
|
||||
loopback_users.guest = false
|
||||
listeners.tcp.default = 5672
|
||||
|
||||
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
|
||||
cluster_formation.classic_config.nodes.1 = rabbit@rabbit-1
|
||||
cluster_formation.classic_config.nodes.2 = rabbit@rabbit-2
|
||||
cluster_formation.classic_config.nodes.3 = rabbit@rabbit-3
|
19
messaging/rabbitmq/kubernetes/rabbit-configmap.yaml
Normal file
19
messaging/rabbitmq/kubernetes/rabbit-configmap.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: rabbitmq-config
|
||||
data:
|
||||
enabled_plugins: |
|
||||
[rabbitmq_federation,rabbitmq_management,rabbitmq_peer_discovery_k8s].
|
||||
rabbitmq.conf: |
|
||||
loopback_users.guest = false
|
||||
listeners.tcp.default = 5672
|
||||
|
||||
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_k8s
|
||||
cluster_formation.k8s.host = kubernetes.default.svc.cluster.local
|
||||
cluster_formation.k8s.address_type = hostname
|
||||
cluster_formation.node_cleanup.only_log_warning = true
|
||||
##cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
|
||||
##cluster_formation.classic_config.nodes.1 = rabbit@rabbitmq-0.rabbitmq.rabbits.svc.cluster.local
|
||||
##cluster_formation.classic_config.nodes.2 = rabbit@rabbitmq-1.rabbitmq.rabbits.svc.cluster.local
|
||||
##cluster_formation.classic_config.nodes.3 = rabbit@rabbitmq-2.rabbitmq.rabbits.svc.cluster.local
|
32
messaging/rabbitmq/kubernetes/rabbit-rbac.yaml
Normal file
32
messaging/rabbitmq/kubernetes/rabbit-rbac.yaml
Normal file
@ -0,0 +1,32 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: rabbitmq
|
||||
---
|
||||
kind: Role
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: rabbitmq
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- endpoints
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
---
|
||||
kind: RoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: rabbitmq
|
||||
namespace: rabbits
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: rabbitmq
|
||||
namespace: rabbits
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: rabbitmq
|
8
messaging/rabbitmq/kubernetes/rabbit-secret.yaml
Normal file
8
messaging/rabbitmq/kubernetes/rabbit-secret.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: rabbit-secret
|
||||
type: Opaque
|
||||
data:
|
||||
# echo -n "cookie-value" | base64
|
||||
RABBITMQ_ERLANG_COOKIE: V0lXVkhDRFRDSVVBV0FOTE1RQVc=
|
101
messaging/rabbitmq/kubernetes/rabbit-statefulset.yaml
Normal file
101
messaging/rabbitmq/kubernetes/rabbit-statefulset.yaml
Normal file
@ -0,0 +1,101 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: rabbitmq
|
||||
spec:
|
||||
serviceName: rabbitmq
|
||||
replicas: 4
|
||||
selector:
|
||||
matchLabels:
|
||||
app: rabbitmq
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: rabbitmq
|
||||
spec:
|
||||
serviceAccountName: rabbitmq
|
||||
initContainers:
|
||||
- name: config
|
||||
image: busybox
|
||||
command: ['/bin/sh', '-c', 'cp /tmp/config/rabbitmq.conf /config/rabbitmq.conf && ls -l /config/ && cp /tmp/config/enabled_plugins /etc/rabbitmq/enabled_plugins']
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /tmp/config/
|
||||
readOnly: false
|
||||
- name: config-file
|
||||
mountPath: /config/
|
||||
- name: plugins-file
|
||||
mountPath: /etc/rabbitmq/
|
||||
containers:
|
||||
- name: rabbitmq
|
||||
image: rabbitmq:3.8-management
|
||||
ports:
|
||||
- containerPort: 4369
|
||||
name: discovery
|
||||
- containerPort: 5672
|
||||
name: amqp
|
||||
env:
|
||||
- name: RABBIT_POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: metadata.name
|
||||
- name: RABBIT_POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: RABBITMQ_NODENAME
|
||||
value: rabbit@$(RABBIT_POD_NAME).rabbitmq.$(RABBIT_POD_NAMESPACE).svc.cluster.local
|
||||
- name: RABBITMQ_USE_LONGNAME
|
||||
value: "true"
|
||||
- name: RABBITMQ_CONFIG_FILE
|
||||
value: "/config/rabbitmq"
|
||||
- name: RABBITMQ_ERLANG_COOKIE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: rabbit-secret
|
||||
key: RABBITMQ_ERLANG_COOKIE
|
||||
- name: K8S_HOSTNAME_SUFFIX
|
||||
value: .rabbitmq.$(RABBIT_POD_NAMESPACE).svc.cluster.local
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /var/lib/rabbitmq
|
||||
readOnly: false
|
||||
- name: config-file
|
||||
mountPath: /config/
|
||||
- name: plugins-file
|
||||
mountPath: /etc/rabbitmq/
|
||||
volumes:
|
||||
- name: config-file
|
||||
emptyDir: {}
|
||||
- name: plugins-file
|
||||
emptyDir: {}
|
||||
- name: config
|
||||
configMap:
|
||||
name: rabbitmq-config
|
||||
defaultMode: 0755
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes: [ "ReadWriteOnce" ]
|
||||
storageClassName: "standard"
|
||||
resources:
|
||||
requests:
|
||||
storage: 50Mi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: rabbitmq
|
||||
spec:
|
||||
clusterIP: None
|
||||
ports:
|
||||
- port: 4369
|
||||
targetPort: 4369
|
||||
name: discovery
|
||||
- port: 5672
|
||||
targetPort: 5672
|
||||
name: amqp
|
||||
selector:
|
||||
app: rabbitmq
|
60
messaging/rabbitmq/kubernetes/readme.md
Normal file
60
messaging/rabbitmq/kubernetes/readme.md
Normal file
@ -0,0 +1,60 @@
|
||||
# RabbitMQ on Kubernetes
|
||||
|
||||
Create a cluster with [kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
|
||||
|
||||
```
|
||||
kind create cluster --name rabbit --image kindest/node:v1.18.4
|
||||
```
|
||||
|
||||
## Namespace
|
||||
|
||||
```
|
||||
kubectl create ns rabbits
|
||||
```
|
||||
|
||||
## Storage Class
|
||||
|
||||
```
|
||||
kubectl get storageclass
|
||||
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
|
||||
standard (default) rancher.io/local-path Delete WaitForFirstConsumer false 84s
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
```
|
||||
kubectl apply -n rabbits -f .\kubernetes\rabbit-rbac.yaml
|
||||
kubectl apply -n rabbits -f .\kubernetes\rabbit-configmap.yaml
|
||||
kubectl apply -n rabbits -f .\kubernetes\rabbit-secret.yaml
|
||||
kubectl apply -n rabbits -f .\kubernetes\rabbit-statefulset.yaml
|
||||
```
|
||||
|
||||
## Access the UI
|
||||
|
||||
```
|
||||
kubectl -n rabbits port-forward rabbitmq-0 8080:15672
|
||||
```
|
||||
Go to htttp://localhost:8080 <br/>
|
||||
Username: `guest` <br/>
|
||||
Password: `guest` <br/>
|
||||
|
||||
# Message Publisher
|
||||
|
||||
```
|
||||
|
||||
cd messaging\rabbitmq\applications\publisher
|
||||
docker build . -t aimvector/rabbitmq-publisher:v1.0.0
|
||||
|
||||
kubectl apply -f rabbits deployment.yaml
|
||||
```
|
||||
|
||||
# Automatic Synchronization
|
||||
|
||||
https://www.rabbitmq.com/ha.html#unsynchronised-mirrors
|
||||
|
||||
```
|
||||
rabbitmqctl set_policy ha-fed \
|
||||
".*" '{"federation-upstream-set":"all", "ha-sync-mode":"automatic", "ha-mode":"nodes", "ha-params":["rabbit@rabbitmq-0.rabbitmq.rabbits.svc.cluster.local","rabbit@rabbitmq-1.rabbitmq.rabbits.svc.cluster.local","rabbit@rabbitmq-2.rabbitmq.rabbits.svc.cluster.local"]}' \
|
||||
--priority 1 \
|
||||
--apply-to queues
|
||||
```
|
165
messaging/rabbitmq/readme.md
Normal file
165
messaging/rabbitmq/readme.md
Normal file
@ -0,0 +1,165 @@
|
||||
# RabbitMQ
|
||||
|
||||
Docker image over [here](https://hub.docker.com/_/rabbitmq)
|
||||
```
|
||||
# run a standalone instance
|
||||
docker network create rabbits
|
||||
docker run -d --rm --net rabbits --hostname rabbit-1 --name rabbit-1 rabbitmq:3.8
|
||||
|
||||
# how to grab existing erlang cookie
|
||||
docker exec -it rabbit-1 cat /var/lib/rabbitmq/.erlang.cookie
|
||||
|
||||
# clean up
|
||||
docker rm -f rabbit-1
|
||||
```
|
||||
|
||||
# Management
|
||||
|
||||
```
|
||||
docker run -d --rm --net rabbits -p 8080:15672 -e RABBITMQ_ERLANG_COOKIE=DSHEVCXBBETJJVJWTOWT --hostname rabbit-manager --name rabbit-manager rabbitmq:3.8-management
|
||||
|
||||
#join the manager
|
||||
|
||||
docker exec -it rabbit-manager rabbitmqctl stop_app
|
||||
docker exec -it rabbit-manager rabbitmqctl reset
|
||||
docker exec -it rabbit-manager rabbitmqctl join_cluster rabbit@rabbit-1
|
||||
docker exec -it rabbit-manager rabbitmqctl start_app
|
||||
docker exec -it rabbit-manager rabbitmqctl cluster_status
|
||||
```
|
||||
|
||||
# Enable Statistics
|
||||
|
||||
docker exec -it rabbit-1 rabbitmq-plugins enable rabbitmq_management
|
||||
docker exec -it rabbit-2 rabbitmq-plugins enable rabbitmq_management
|
||||
docker exec -it rabbit-3 rabbitmq-plugins enable rabbitmq_management
|
||||
|
||||
# Message Publisher
|
||||
|
||||
```
|
||||
|
||||
cd messaging\rabbitmq\applications\publisher
|
||||
docker build . -t aimvector/rabbitmq-publisher:v1.0.0
|
||||
|
||||
docker run -it --rm --net rabbits -e RABBIT_HOST=rabbit-1 -e RABBIT_PORT=5672 -e RABBIT_USERNAME=guest -e RABBIT_PASSWORD=guest -p 80:80 aimvector/rabbitmq-publisher:v1.0.0
|
||||
```
|
||||
|
||||
# Message Consumer
|
||||
|
||||
```
|
||||
|
||||
docker build . -t aimvector/rabbitmq-consumer:v1.0.0
|
||||
docker run -it --rm --net rabbits -e RABBIT_HOST=rabbit-1 -e RABBIT_PORT=5672 -e RABBIT_USERNAME=guest -e RABBIT_PASSWORD=guest aimvector/rabbitmq-consumer:v1.0.0
|
||||
```
|
||||
|
||||
# Clustering
|
||||
|
||||
https://www.rabbitmq.com/cluster-formation.html
|
||||
|
||||
## Note
|
||||
|
||||
Remember we will need the Erlang Cookie to allow instances to authenticate with each other.
|
||||
|
||||
# Manual Clustering
|
||||
|
||||
```
|
||||
|
||||
docker exec -it rabbit-1 rabbitmqctl cluster_status
|
||||
|
||||
#join node 2
|
||||
|
||||
docker exec -it rabbit-2 rabbitmqctl stop_app
|
||||
docker exec -it rabbit-2 rabbitmqctl reset
|
||||
docker exec -it rabbit-2 rabbitmqctl join_cluster rabbit@rabbit-1
|
||||
docker exec -it rabbit-2 rabbitmqctl start_app
|
||||
docker exec -it rabbit-2 rabbitmqctl cluster_status
|
||||
|
||||
#join node 3
|
||||
docker exec -it rabbit-3 rabbitmqctl stop_app
|
||||
docker exec -it rabbit-3 rabbitmqctl reset
|
||||
docker exec -it rabbit-3 rabbitmqctl join_cluster rabbit@rabbit-1
|
||||
docker exec -it rabbit-3 rabbitmqctl start_app
|
||||
docker exec -it rabbit-3 rabbitmqctl cluster_status
|
||||
|
||||
```
|
||||
|
||||
# Automated Clustering
|
||||
|
||||
```
|
||||
docker run -d --rm --net rabbits `
|
||||
-v ${PWD}/config/rabbit-1/:/config/ `
|
||||
-e RABBITMQ_CONFIG_FILE=/config/rabbitmq `
|
||||
-e RABBITMQ_ERLANG_COOKIE=WIWVHCDTCIUAWANLMQAW `
|
||||
--hostname rabbit-1 `
|
||||
--name rabbit-1 `
|
||||
-p 8081:15672 `
|
||||
rabbitmq:3.8-management
|
||||
|
||||
docker run -d --rm --net rabbits `
|
||||
-v ${PWD}/config/rabbit-2/:/config/ `
|
||||
-e RABBITMQ_CONFIG_FILE=/config/rabbitmq `
|
||||
-e RABBITMQ_ERLANG_COOKIE=WIWVHCDTCIUAWANLMQAW `
|
||||
--hostname rabbit-2 `
|
||||
--name rabbit-2 `
|
||||
-p 8082:15672 `
|
||||
rabbitmq:3.8-management
|
||||
|
||||
docker run -d --rm --net rabbits `
|
||||
-v ${PWD}/config/rabbit-3/:/config/ `
|
||||
-e RABBITMQ_CONFIG_FILE=/config/rabbitmq `
|
||||
-e RABBITMQ_ERLANG_COOKIE=WIWVHCDTCIUAWANLMQAW `
|
||||
--hostname rabbit-3 `
|
||||
--name rabbit-3 `
|
||||
-p 8083:15672 `
|
||||
rabbitmq:3.8-management
|
||||
|
||||
#NODE 1 : MANAGEMENT http://localhost:8081
|
||||
#NODE 2 : MANAGEMENT http://localhost:8082
|
||||
#NODE 3 : MANAGEMENT http://localhost:8083
|
||||
|
||||
# enable federation plugin
|
||||
docker exec -it rabbit-1 rabbitmq-plugins enable rabbitmq_federation
|
||||
docker exec -it rabbit-2 rabbitmq-plugins enable rabbitmq_federation
|
||||
docker exec -it rabbit-3 rabbitmq-plugins enable rabbitmq_federation
|
||||
|
||||
```
|
||||
|
||||
# Basic Queue Mirroring
|
||||
|
||||
```
|
||||
docker exec -it rabbit-1 bash
|
||||
|
||||
# https://www.rabbitmq.com/ha.html#mirroring-arguments
|
||||
|
||||
rabbitmqctl set_policy ha-fed \
|
||||
".*" '{"federation-upstream-set":"all", "ha-mode":"nodes", "ha-params":["rabbit@rabbit-1","rabbit@rabbit-2","rabbit@rabbit-3"]}' \
|
||||
--priority 1 \
|
||||
--apply-to queues
|
||||
```
|
||||
|
||||
# Automatic Synchronization
|
||||
|
||||
https://www.rabbitmq.com/ha.html#unsynchronised-mirrors
|
||||
|
||||
```
|
||||
rabbitmqctl set_policy ha-fed \
|
||||
".*" '{"federation-upstream-set":"all", "ha-sync-mode":"automatic", "ha-mode":"nodes", "ha-params":["rabbit@rabbit-1","rabbit@rabbit-2","rabbit@rabbit-3"]}' \
|
||||
--priority 1 \
|
||||
--apply-to queues
|
||||
```
|
||||
|
||||
# Further Reading
|
||||
|
||||
https://www.rabbitmq.com/ha.html
|
||||
|
||||
|
||||
# Clean up
|
||||
|
||||
```
|
||||
docker rm -f rabbit-1
|
||||
docker rm -f rabbit-2
|
||||
docker rm -f rabbit-3
|
||||
```
|
||||
|
||||
# RabbitMQ on Kubernetes
|
||||
|
||||
Checkout the Kubernetes walkthrough [here](./kubernetes/readme.md)
|
@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
data:
|
||||
alertmanager.yaml: Imdsb2JhbCI6CiAgInJlc29sdmVfdGltZW91dCI6ICI1bSIKInJlY2VpdmVycyI6Ci0gIm5hbWUiOiAibnVsbCIKInJvdXRlIjoKICAiZ3JvdXBfYnkiOgogIC0gImpvYiIKICAiZ3JvdXBfaW50ZXJ2YWwiOiAiNW0iCiAgImdyb3VwX3dhaXQiOiAiMzBzIgogICJyZWNlaXZlciI6ICJudWxsIgogICJyZXBlYXRfaW50ZXJ2YWwiOiAiMTJoIgogICJyb3V0ZXMiOgogIC0gIm1hdGNoIjoKICAgICAgImFsZXJ0bmFtZSI6ICJXYXRjaGRvZyIKICAgICJyZWNlaXZlciI6ICJudWxsIg==
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: alertmanager-main
|
||||
namespace: monitoring
|
||||
type: Opaque
|
@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: alertmanager-main
|
||||
namespace: monitoring
|
@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
alertmanager: main
|
||||
name: alertmanager-main
|
||||
namespace: monitoring
|
||||
spec:
|
||||
ports:
|
||||
- name: web
|
||||
port: 9093
|
||||
targetPort: web
|
||||
selector:
|
||||
alertmanager: main
|
||||
app: alertmanager
|
||||
sessionAffinity: ClientIP
|
@ -0,0 +1,14 @@
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: alertmanager
|
||||
name: alertmanager
|
||||
namespace: monitoring
|
||||
spec:
|
||||
endpoints:
|
||||
- interval: 30s
|
||||
port: web
|
||||
selector:
|
||||
matchLabels:
|
||||
alertmanager: main
|
@ -0,0 +1,18 @@
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: Alertmanager
|
||||
metadata:
|
||||
labels:
|
||||
alertmanager: main
|
||||
name: main
|
||||
namespace: monitoring
|
||||
spec:
|
||||
baseImage: quay.io/prometheus/alertmanager
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
replicas: 3
|
||||
securityContext:
|
||||
fsGroup: 2000
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
serviceAccountName: alertmanager-main
|
||||
version: v0.18.0
|
@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
data:
|
||||
datasources.yaml: ewogICAgImFwaVZlcnNpb24iOiAxLAogICAgImRhdGFzb3VyY2VzIjogWwogICAgICAgIHsKICAgICAgICAgICAgImFjY2VzcyI6ICJwcm94eSIsCiAgICAgICAgICAgICJlZGl0YWJsZSI6IGZhbHNlLAogICAgICAgICAgICAibmFtZSI6ICJwcm9tZXRoZXVzIiwKICAgICAgICAgICAgIm9yZ0lkIjogMSwKICAgICAgICAgICAgInR5cGUiOiAicHJvbWV0aGV1cyIsCiAgICAgICAgICAgICJ1cmwiOiAiaHR0cDovL3Byb21ldGhldXMtazhzLm1vbml0b3Jpbmcuc3ZjOjkwOTAiLAogICAgICAgICAgICAidmVyc2lvbiI6IDEKICAgICAgICB9CiAgICBdCn0=
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: grafana-datasources
|
||||
namespace: monitoring
|
||||
type: Opaque
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
apiVersion: v1
|
||||
data:
|
||||
dashboards.yaml: |-
|
||||
{
|
||||
"apiVersion": 1,
|
||||
"providers": [
|
||||
{
|
||||
"folder": "",
|
||||
"name": "0",
|
||||
"options": {
|
||||
"path": "/grafana-dashboard-definitions/0"
|
||||
},
|
||||
"orgId": 1,
|
||||
"type": "file"
|
||||
}
|
||||
]
|
||||
}
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: grafana-dashboards
|
||||
namespace: monitoring
|
@ -0,0 +1,208 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: grafana
|
||||
name: grafana
|
||||
namespace: monitoring
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: grafana
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: grafana
|
||||
spec:
|
||||
containers:
|
||||
- image: grafana/grafana:6.4.3
|
||||
name: grafana
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
name: http
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/health
|
||||
port: http
|
||||
resources:
|
||||
limits:
|
||||
cpu: 200m
|
||||
memory: 200Mi
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
volumeMounts:
|
||||
- mountPath: /var/lib/grafana
|
||||
name: grafana-storage
|
||||
readOnly: false
|
||||
- mountPath: /etc/grafana/provisioning/datasources
|
||||
name: grafana-datasources
|
||||
readOnly: false
|
||||
- mountPath: /etc/grafana/provisioning/dashboards
|
||||
name: grafana-dashboards
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/nodeexporter
|
||||
name: grafana-dashboard-nodeexporter
|
||||
- mountPath: /grafana-dashboard-definitions/0/apiserver
|
||||
name: grafana-dashboard-apiserver
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/cluster-total
|
||||
name: grafana-dashboard-cluster-total
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/controller-manager
|
||||
name: grafana-dashboard-controller-manager
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/k8s-resources-cluster
|
||||
name: grafana-dashboard-k8s-resources-cluster
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/k8s-resources-namespace
|
||||
name: grafana-dashboard-k8s-resources-namespace
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/k8s-resources-node
|
||||
name: grafana-dashboard-k8s-resources-node
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/k8s-resources-pod
|
||||
name: grafana-dashboard-k8s-resources-pod
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/k8s-resources-workload
|
||||
name: grafana-dashboard-k8s-resources-workload
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/k8s-resources-workloads-namespace
|
||||
name: grafana-dashboard-k8s-resources-workloads-namespace
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/kubelet
|
||||
name: grafana-dashboard-kubelet
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/namespace-by-pod
|
||||
name: grafana-dashboard-namespace-by-pod
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/namespace-by-workload
|
||||
name: grafana-dashboard-namespace-by-workload
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/node-cluster-rsrc-use
|
||||
name: grafana-dashboard-node-cluster-rsrc-use
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/node-rsrc-use
|
||||
name: grafana-dashboard-node-rsrc-use
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/nodes
|
||||
name: grafana-dashboard-nodes
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/persistentvolumesusage
|
||||
name: grafana-dashboard-persistentvolumesusage
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/pod-total
|
||||
name: grafana-dashboard-pod-total
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/pods
|
||||
name: grafana-dashboard-pods
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/prometheus-remote-write
|
||||
name: grafana-dashboard-prometheus-remote-write
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/prometheus
|
||||
name: grafana-dashboard-prometheus
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/proxy
|
||||
name: grafana-dashboard-proxy
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/scheduler
|
||||
name: grafana-dashboard-scheduler
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/statefulset
|
||||
name: grafana-dashboard-statefulset
|
||||
readOnly: false
|
||||
- mountPath: /grafana-dashboard-definitions/0/workload-total
|
||||
name: grafana-dashboard-workload-total
|
||||
readOnly: false
|
||||
nodeSelector:
|
||||
beta.kubernetes.io/os: linux
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
serviceAccountName: grafana
|
||||
volumes:
|
||||
- emptyDir: {}
|
||||
name: grafana-storage
|
||||
- name: grafana-datasources
|
||||
secret:
|
||||
secretName: grafana-datasources
|
||||
- configMap:
|
||||
name: grafana-dashboards
|
||||
name: grafana-dashboards
|
||||
- configMap:
|
||||
name: grafana-dashboard-nodeexporter
|
||||
name: grafana-dashboard-nodeexporter
|
||||
- configMap:
|
||||
name: grafana-dashboard-apiserver
|
||||
name: grafana-dashboard-apiserver
|
||||
- configMap:
|
||||
name: grafana-dashboard-cluster-total
|
||||
name: grafana-dashboard-cluster-total
|
||||
- configMap:
|
||||
name: grafana-dashboard-controller-manager
|
||||
name: grafana-dashboard-controller-manager
|
||||
- configMap:
|
||||
name: grafana-dashboard-k8s-resources-cluster
|
||||
name: grafana-dashboard-k8s-resources-cluster
|
||||
- configMap:
|
||||
name: grafana-dashboard-k8s-resources-namespace
|
||||
name: grafana-dashboard-k8s-resources-namespace
|
||||
- configMap:
|
||||
name: grafana-dashboard-k8s-resources-node
|
||||
name: grafana-dashboard-k8s-resources-node
|
||||
- configMap:
|
||||
name: grafana-dashboard-k8s-resources-pod
|
||||
name: grafana-dashboard-k8s-resources-pod
|
||||
- configMap:
|
||||
name: grafana-dashboard-k8s-resources-workload
|
||||
name: grafana-dashboard-k8s-resources-workload
|
||||
- configMap:
|
||||
name: grafana-dashboard-k8s-resources-workloads-namespace
|
||||
name: grafana-dashboard-k8s-resources-workloads-namespace
|
||||
- configMap:
|
||||
name: grafana-dashboard-kubelet
|
||||
name: grafana-dashboard-kubelet
|
||||
- configMap:
|
||||
name: grafana-dashboard-namespace-by-pod
|
||||
name: grafana-dashboard-namespace-by-pod
|
||||
- configMap:
|
||||
name: grafana-dashboard-namespace-by-workload
|
||||
name: grafana-dashboard-namespace-by-workload
|
||||
- configMap:
|
||||
name: grafana-dashboard-node-cluster-rsrc-use
|
||||
name: grafana-dashboard-node-cluster-rsrc-use
|
||||
- configMap:
|
||||
name: grafana-dashboard-node-rsrc-use
|
||||
name: grafana-dashboard-node-rsrc-use
|
||||
- configMap:
|
||||
name: grafana-dashboard-nodes
|
||||
name: grafana-dashboard-nodes
|
||||
- configMap:
|
||||
name: grafana-dashboard-persistentvolumesusage
|
||||
name: grafana-dashboard-persistentvolumesusage
|
||||
- configMap:
|
||||
name: grafana-dashboard-pod-total
|
||||
name: grafana-dashboard-pod-total
|
||||
- configMap:
|
||||
name: grafana-dashboard-pods
|
||||
name: grafana-dashboard-pods
|
||||
- configMap:
|
||||
name: grafana-dashboard-prometheus-remote-write
|
||||
name: grafana-dashboard-prometheus-remote-write
|
||||
- configMap:
|
||||
name: grafana-dashboard-prometheus
|
||||
name: grafana-dashboard-prometheus
|
||||
- configMap:
|
||||
name: grafana-dashboard-proxy
|
||||
name: grafana-dashboard-proxy
|
||||
- configMap:
|
||||
name: grafana-dashboard-scheduler
|
||||
name: grafana-dashboard-scheduler
|
||||
- configMap:
|
||||
name: grafana-dashboard-statefulset
|
||||
name: grafana-dashboard-statefulset
|
||||
- configMap:
|
||||
name: grafana-dashboard-workload-total
|
||||
name: grafana-dashboard-workload-total
|
@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: grafana
|
||||
namespace: monitoring
|
@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: grafana
|
||||
name: grafana
|
||||
namespace: monitoring
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 3000
|
||||
targetPort: http
|
||||
selector:
|
||||
app: grafana
|
@ -0,0 +1,12 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: kube-state-metrics
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: kube-state-metrics
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: kube-state-metrics
|
||||
namespace: monitoring
|
@ -0,0 +1,91 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: kube-state-metrics
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- configmaps
|
||||
- secrets
|
||||
- nodes
|
||||
- pods
|
||||
- services
|
||||
- resourcequotas
|
||||
- replicationcontrollers
|
||||
- limitranges
|
||||
- persistentvolumeclaims
|
||||
- persistentvolumes
|
||||
- namespaces
|
||||
- endpoints
|
||||
verbs:
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- extensions
|
||||
resources:
|
||||
- daemonsets
|
||||
- deployments
|
||||
- replicasets
|
||||
- ingresses
|
||||
verbs:
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- apps
|
||||
resources:
|
||||
- statefulsets
|
||||
- daemonsets
|
||||
- deployments
|
||||
- replicasets
|
||||
verbs:
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- batch
|
||||
resources:
|
||||
- cronjobs
|
||||
- jobs
|
||||
verbs:
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- autoscaling
|
||||
resources:
|
||||
- horizontalpodautoscalers
|
||||
verbs:
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- authentication.k8s.io
|
||||
resources:
|
||||
- tokenreviews
|
||||
verbs:
|
||||
- create
|
||||
- apiGroups:
|
||||
- authorization.k8s.io
|
||||
resources:
|
||||
- subjectaccessreviews
|
||||
verbs:
|
||||
- create
|
||||
- apiGroups:
|
||||
- policy
|
||||
resources:
|
||||
- poddisruptionbudgets
|
||||
verbs:
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- certificates.k8s.io
|
||||
resources:
|
||||
- certificatesigningrequests
|
||||
verbs:
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- storage.k8s.io
|
||||
resources:
|
||||
- storageclasses
|
||||
verbs:
|
||||
- list
|
||||
- watch
|
@ -0,0 +1,72 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: kube-state-metrics
|
||||
name: kube-state-metrics
|
||||
namespace: monitoring
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: kube-state-metrics
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: kube-state-metrics
|
||||
spec:
|
||||
containers:
|
||||
- args:
|
||||
- --logtostderr
|
||||
- --secure-listen-address=:8443
|
||||
- --tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
|
||||
- --upstream=http://127.0.0.1:8081/
|
||||
image: quay.io/coreos/kube-rbac-proxy:v0.4.1
|
||||
name: kube-rbac-proxy-main
|
||||
ports:
|
||||
- containerPort: 8443
|
||||
name: https-main
|
||||
resources:
|
||||
limits:
|
||||
cpu: 20m
|
||||
memory: 40Mi
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 20Mi
|
||||
- args:
|
||||
- --logtostderr
|
||||
- --secure-listen-address=:9443
|
||||
- --tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
|
||||
- --upstream=http://127.0.0.1:8082/
|
||||
image: quay.io/coreos/kube-rbac-proxy:v0.4.1
|
||||
name: kube-rbac-proxy-self
|
||||
ports:
|
||||
- containerPort: 9443
|
||||
name: https-self
|
||||
resources:
|
||||
limits:
|
||||
cpu: 20m
|
||||
memory: 40Mi
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 20Mi
|
||||
- args:
|
||||
- --host=127.0.0.1
|
||||
- --port=8081
|
||||
- --telemetry-host=127.0.0.1
|
||||
- --telemetry-port=8082
|
||||
image: quay.io/coreos/kube-state-metrics:v1.8.0
|
||||
name: kube-state-metrics
|
||||
resources:
|
||||
limits:
|
||||
cpu: 100m
|
||||
memory: 150Mi
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 150Mi
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
serviceAccountName: kube-state-metrics
|
@ -0,0 +1,12 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: kube-state-metrics
|
||||
namespace: monitoring
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: kube-state-metrics
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: kube-state-metrics
|
@ -0,0 +1,30 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: kube-state-metrics
|
||||
namespace: monitoring
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- pods
|
||||
verbs:
|
||||
- get
|
||||
- apiGroups:
|
||||
- extensions
|
||||
resourceNames:
|
||||
- kube-state-metrics
|
||||
resources:
|
||||
- deployments
|
||||
verbs:
|
||||
- get
|
||||
- update
|
||||
- apiGroups:
|
||||
- apps
|
||||
resourceNames:
|
||||
- kube-state-metrics
|
||||
resources:
|
||||
- deployments
|
||||
verbs:
|
||||
- get
|
||||
- update
|
@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: kube-state-metrics
|
||||
namespace: monitoring
|
@ -0,0 +1,30 @@
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kube-state-metrics
|
||||
name: kube-state-metrics
|
||||
namespace: monitoring
|
||||
spec:
|
||||
endpoints:
|
||||
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
|
||||
honorLabels: true
|
||||
interval: 30s
|
||||
port: https-main
|
||||
relabelings:
|
||||
- action: labeldrop
|
||||
regex: (pod|service|endpoint|namespace)
|
||||
scheme: https
|
||||
scrapeTimeout: 30s
|
||||
tlsConfig:
|
||||
insecureSkipVerify: true
|
||||
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
|
||||
interval: 30s
|
||||
port: https-self
|
||||
scheme: https
|
||||
tlsConfig:
|
||||
insecureSkipVerify: true
|
||||
jobLabel: k8s-app
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s-app: kube-state-metrics
|
@ -0,0 +1,18 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kube-state-metrics
|
||||
name: kube-state-metrics
|
||||
namespace: monitoring
|
||||
spec:
|
||||
clusterIP: None
|
||||
ports:
|
||||
- name: https-main
|
||||
port: 8443
|
||||
targetPort: https-main
|
||||
- name: https-self
|
||||
port: 9443
|
||||
targetPort: https-self
|
||||
selector:
|
||||
app: kube-state-metrics
|
@ -0,0 +1,12 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: node-exporter
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: node-exporter
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: node-exporter
|
||||
namespace: monitoring
|
@ -0,0 +1,17 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: node-exporter
|
||||
rules:
|
||||
- apiGroups:
|
||||
- authentication.k8s.io
|
||||
resources:
|
||||
- tokenreviews
|
||||
verbs:
|
||||
- create
|
||||
- apiGroups:
|
||||
- authorization.k8s.io
|
||||
resources:
|
||||
- subjectaccessreviews
|
||||
verbs:
|
||||
- create
|
@ -0,0 +1,87 @@
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
labels:
|
||||
app: node-exporter
|
||||
name: node-exporter
|
||||
namespace: monitoring
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: node-exporter
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: node-exporter
|
||||
spec:
|
||||
containers:
|
||||
- args:
|
||||
- --web.listen-address=127.0.0.1:9100
|
||||
- --path.procfs=/host/proc
|
||||
- --path.sysfs=/host/sys
|
||||
- --path.rootfs=/host/root
|
||||
- --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+)($|/)
|
||||
- --collector.filesystem.ignored-fs-types=^(autofs|binfmt_misc|cgroup|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|sysfs|tracefs)$
|
||||
image: quay.io/prometheus/node-exporter:v0.18.1
|
||||
name: node-exporter
|
||||
resources:
|
||||
limits:
|
||||
cpu: 250m
|
||||
memory: 180Mi
|
||||
requests:
|
||||
cpu: 102m
|
||||
memory: 180Mi
|
||||
volumeMounts:
|
||||
- mountPath: /host/proc
|
||||
name: proc
|
||||
readOnly: false
|
||||
- mountPath: /host/sys
|
||||
name: sys
|
||||
readOnly: false
|
||||
- mountPath: /host/root
|
||||
mountPropagation: HostToContainer
|
||||
name: root
|
||||
readOnly: true
|
||||
- args:
|
||||
- --logtostderr
|
||||
- --secure-listen-address=$(IP):9100
|
||||
- --tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
|
||||
- --upstream=http://127.0.0.1:9100/
|
||||
env:
|
||||
- name: IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.podIP
|
||||
image: quay.io/coreos/kube-rbac-proxy:v0.4.1
|
||||
name: kube-rbac-proxy
|
||||
ports:
|
||||
- containerPort: 9100
|
||||
hostPort: 9100
|
||||
name: https
|
||||
resources:
|
||||
limits:
|
||||
cpu: 20m
|
||||
memory: 40Mi
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 20Mi
|
||||
hostNetwork: true
|
||||
hostPID: true
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
serviceAccountName: node-exporter
|
||||
tolerations:
|
||||
- operator: Exists
|
||||
volumes:
|
||||
- hostPath:
|
||||
path: /proc
|
||||
name: proc
|
||||
- hostPath:
|
||||
path: /sys
|
||||
name: sys
|
||||
- hostPath:
|
||||
path: /
|
||||
name: root
|
@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: node-exporter
|
||||
namespace: monitoring
|
@ -0,0 +1,26 @@
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: node-exporter
|
||||
name: node-exporter
|
||||
namespace: monitoring
|
||||
spec:
|
||||
endpoints:
|
||||
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
|
||||
interval: 30s
|
||||
port: https
|
||||
relabelings:
|
||||
- action: replace
|
||||
regex: (.*)
|
||||
replacement: $1
|
||||
sourceLabels:
|
||||
- __meta_kubernetes_pod_node_name
|
||||
targetLabel: instance
|
||||
scheme: https
|
||||
tlsConfig:
|
||||
insecureSkipVerify: true
|
||||
jobLabel: k8s-app
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s-app: node-exporter
|
@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: node-exporter
|
||||
name: node-exporter
|
||||
namespace: monitoring
|
||||
spec:
|
||||
clusterIP: None
|
||||
ports:
|
||||
- name: https
|
||||
port: 9100
|
||||
targetPort: https
|
||||
selector:
|
||||
app: node-exporter
|
@ -0,0 +1,12 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: prometheus-k8s
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: prometheus-k8s
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: prometheus-k8s
|
||||
namespace: monitoring
|
@ -0,0 +1,25 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: prometheus-k8s
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- nodes/metrics
|
||||
verbs:
|
||||
- get
|
||||
- nonResourceURLs:
|
||||
- /metrics
|
||||
verbs:
|
||||
- get
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- services
|
||||
- endpoints
|
||||
- pods
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
prometheus: k8s
|
||||
name: prometheus-k8s
|
||||
namespace: monitoring
|
||||
spec:
|
||||
ports:
|
||||
- name: web
|
||||
port: 9090
|
||||
targetPort: web
|
||||
selector:
|
||||
app: prometheus
|
||||
prometheus: k8s
|
||||
sessionAffinity: ClientIP
|
@ -0,0 +1,40 @@
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: Prometheus
|
||||
metadata:
|
||||
labels:
|
||||
prometheus: k8s
|
||||
name: k8s
|
||||
namespace: monitoring
|
||||
spec:
|
||||
alerting:
|
||||
alertmanagers:
|
||||
- name: alertmanager-main
|
||||
namespace: monitoring
|
||||
port: web
|
||||
baseImage: quay.io/prometheus/prometheus
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
podMonitorSelector: {}
|
||||
replicas: 2
|
||||
# resources:
|
||||
# requests:
|
||||
# memory: 400Mi
|
||||
ruleSelector:
|
||||
matchLabels:
|
||||
prometheus: k8s
|
||||
role: alert-rules
|
||||
securityContext:
|
||||
fsGroup: 2000
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
serviceAccountName: prometheus-k8s
|
||||
serviceMonitorSelector:
|
||||
matchExpressions:
|
||||
- key: k8s-app
|
||||
operator: In
|
||||
values:
|
||||
- node-exporter
|
||||
- kube-state-metrics
|
||||
- apiserver
|
||||
- kubelet
|
||||
version: v2.11.0
|
@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: prometheus-k8s
|
||||
namespace: monitoring
|
@ -0,0 +1,37 @@
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: apiserver
|
||||
name: kube-apiserver
|
||||
namespace: monitoring
|
||||
spec:
|
||||
endpoints:
|
||||
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
|
||||
interval: 30s
|
||||
metricRelabelings:
|
||||
- action: drop
|
||||
regex: etcd_(debugging|disk|request|server).*
|
||||
sourceLabels:
|
||||
- __name__
|
||||
- action: drop
|
||||
regex: apiserver_admission_controller_admission_latencies_seconds_.*
|
||||
sourceLabels:
|
||||
- __name__
|
||||
- action: drop
|
||||
regex: apiserver_admission_step_admission_latencies_seconds_.*
|
||||
sourceLabels:
|
||||
- __name__
|
||||
port: https
|
||||
scheme: https
|
||||
tlsConfig:
|
||||
caFile: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||
serverName: kubernetes
|
||||
jobLabel: component
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- default
|
||||
selector:
|
||||
matchLabels:
|
||||
component: apiserver
|
||||
provider: kubernetes
|
@ -0,0 +1,44 @@
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kubelet
|
||||
name: kubelet
|
||||
namespace: monitoring
|
||||
spec:
|
||||
endpoints:
|
||||
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
|
||||
honorLabels: true
|
||||
interval: 30s
|
||||
port: https-metrics
|
||||
relabelings:
|
||||
- sourceLabels:
|
||||
- __metrics_path__
|
||||
targetLabel: metrics_path
|
||||
scheme: https
|
||||
tlsConfig:
|
||||
insecureSkipVerify: true
|
||||
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
|
||||
honorLabels: true
|
||||
interval: 30s
|
||||
metricRelabelings:
|
||||
- action: drop
|
||||
regex: container_(network_tcp_usage_total|network_udp_usage_total|tasks_state|cpu_load_average_10s)
|
||||
sourceLabels:
|
||||
- __name__
|
||||
path: /metrics/cadvisor
|
||||
port: https-metrics
|
||||
relabelings:
|
||||
- sourceLabels:
|
||||
- __metrics_path__
|
||||
targetLabel: metrics_path
|
||||
scheme: https
|
||||
tlsConfig:
|
||||
insecureSkipVerify: true
|
||||
jobLabel: k8s-app
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- kube-system
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s-app: kubelet
|
@ -0,0 +1,16 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: controller
|
||||
app.kubernetes.io/name: prometheus-operator
|
||||
app.kubernetes.io/version: v0.34.0
|
||||
name: prometheus-operator
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: prometheus-operator
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: prometheus-operator
|
||||
namespace: monitoring
|
@ -0,0 +1,73 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: controller
|
||||
app.kubernetes.io/name: prometheus-operator
|
||||
app.kubernetes.io/version: v0.34.0
|
||||
name: prometheus-operator
|
||||
rules:
|
||||
- apiGroups:
|
||||
- apiextensions.k8s.io
|
||||
resources:
|
||||
- customresourcedefinitions
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- monitoring.coreos.com
|
||||
resources:
|
||||
- alertmanagers
|
||||
- prometheuses
|
||||
- prometheuses/finalizers
|
||||
- alertmanagers/finalizers
|
||||
- servicemonitors
|
||||
- podmonitors
|
||||
- prometheusrules
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- apps
|
||||
resources:
|
||||
- statefulsets
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- configmaps
|
||||
- secrets
|
||||
verbs:
|
||||
- '*'
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- pods
|
||||
verbs:
|
||||
- list
|
||||
- delete
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- services
|
||||
- services/finalizers
|
||||
- endpoints
|
||||
verbs:
|
||||
- get
|
||||
- create
|
||||
- update
|
||||
- delete
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- nodes
|
||||
verbs:
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- namespaces
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,239 @@
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: podmonitors.monitoring.coreos.com
|
||||
spec:
|
||||
group: monitoring.coreos.com
|
||||
names:
|
||||
kind: PodMonitor
|
||||
plural: podmonitors
|
||||
scope: Namespaced
|
||||
validation:
|
||||
openAPIV3Schema:
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation
|
||||
of an object. Servers should convert recognized schemas to the latest
|
||||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this
|
||||
object represents. Servers may infer this from the endpoint the client
|
||||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
spec:
|
||||
description: PodMonitorSpec contains specification parameters for a PodMonitor.
|
||||
properties:
|
||||
jobLabel:
|
||||
description: The label to use to retrieve the job name from.
|
||||
type: string
|
||||
namespaceSelector:
|
||||
description: NamespaceSelector is a selector for selecting either all
|
||||
namespaces or a list of namespaces.
|
||||
properties:
|
||||
any:
|
||||
description: Boolean describing whether all namespaces are selected
|
||||
in contrast to a list restricting them.
|
||||
type: boolean
|
||||
matchNames:
|
||||
description: List of namespace names.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
podMetricsEndpoints:
|
||||
description: A list of endpoints allowed as part of this PodMonitor.
|
||||
items:
|
||||
description: PodMetricsEndpoint defines a scrapeable endpoint of a
|
||||
Kubernetes Pod serving Prometheus metrics.
|
||||
properties:
|
||||
honorLabels:
|
||||
description: HonorLabels chooses the metric's labels on collisions
|
||||
with target labels.
|
||||
type: boolean
|
||||
honorTimestamps:
|
||||
description: HonorTimestamps controls whether Prometheus respects
|
||||
the timestamps present in scraped data.
|
||||
type: boolean
|
||||
interval:
|
||||
description: Interval at which metrics should be scraped
|
||||
type: string
|
||||
metricRelabelings:
|
||||
description: MetricRelabelConfigs to apply to samples before ingestion.
|
||||
items:
|
||||
description: 'RelabelConfig allows dynamic rewriting of the
|
||||
label set, being applied to samples before ingestion. It defines
|
||||
`<metric_relabel_configs>`-section of Prometheus configuration.
|
||||
More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs'
|
||||
properties:
|
||||
action:
|
||||
description: Action to perform based on regex matching.
|
||||
Default is 'replace'
|
||||
type: string
|
||||
modulus:
|
||||
description: Modulus to take of the hash of the source label
|
||||
values.
|
||||
format: int64
|
||||
type: integer
|
||||
regex:
|
||||
description: Regular expression against which the extracted
|
||||
value is matched. defailt is '(.*)'
|
||||
type: string
|
||||
replacement:
|
||||
description: Replacement value against which a regex replace
|
||||
is performed if the regular expression matches. Regex
|
||||
capture groups are available. Default is '$1'
|
||||
type: string
|
||||
separator:
|
||||
description: Separator placed between concatenated source
|
||||
label values. default is ';'.
|
||||
type: string
|
||||
sourceLabels:
|
||||
description: The source labels select values from existing
|
||||
labels. Their content is concatenated using the configured
|
||||
separator and matched against the configured regular expression
|
||||
for the replace, keep, and drop actions.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
targetLabel:
|
||||
description: Label to which the resulting value is written
|
||||
in a replace action. It is mandatory for replace actions.
|
||||
Regex capture groups are available.
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
params:
|
||||
description: Optional HTTP URL parameters
|
||||
type: object
|
||||
path:
|
||||
description: HTTP path to scrape for metrics.
|
||||
type: string
|
||||
port:
|
||||
description: Name of the port this endpoint refers to. Mutually
|
||||
exclusive with targetPort.
|
||||
type: string
|
||||
proxyUrl:
|
||||
description: ProxyURL eg http://proxyserver:2195 Directs scrapes
|
||||
to proxy through this endpoint.
|
||||
type: string
|
||||
relabelings:
|
||||
description: 'RelabelConfigs to apply to samples before ingestion.
|
||||
More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config'
|
||||
items:
|
||||
description: 'RelabelConfig allows dynamic rewriting of the
|
||||
label set, being applied to samples before ingestion. It defines
|
||||
`<metric_relabel_configs>`-section of Prometheus configuration.
|
||||
More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs'
|
||||
properties:
|
||||
action:
|
||||
description: Action to perform based on regex matching.
|
||||
Default is 'replace'
|
||||
type: string
|
||||
modulus:
|
||||
description: Modulus to take of the hash of the source label
|
||||
values.
|
||||
format: int64
|
||||
type: integer
|
||||
regex:
|
||||
description: Regular expression against which the extracted
|
||||
value is matched. defailt is '(.*)'
|
||||
type: string
|
||||
replacement:
|
||||
description: Replacement value against which a regex replace
|
||||
is performed if the regular expression matches. Regex
|
||||
capture groups are available. Default is '$1'
|
||||
type: string
|
||||
separator:
|
||||
description: Separator placed between concatenated source
|
||||
label values. default is ';'.
|
||||
type: string
|
||||
sourceLabels:
|
||||
description: The source labels select values from existing
|
||||
labels. Their content is concatenated using the configured
|
||||
separator and matched against the configured regular expression
|
||||
for the replace, keep, and drop actions.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
targetLabel:
|
||||
description: Label to which the resulting value is written
|
||||
in a replace action. It is mandatory for replace actions.
|
||||
Regex capture groups are available.
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
scheme:
|
||||
description: HTTP scheme to use for scraping.
|
||||
type: string
|
||||
scrapeTimeout:
|
||||
description: Timeout after which the scrape is ended
|
||||
type: string
|
||||
targetPort:
|
||||
anyOf:
|
||||
- type: string
|
||||
- type: integer
|
||||
type: object
|
||||
type: array
|
||||
podTargetLabels:
|
||||
description: PodTargetLabels transfers labels on the Kubernetes Pod
|
||||
onto the target.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
sampleLimit:
|
||||
description: SampleLimit defines per-scrape limit on number of scraped
|
||||
samples that will be accepted.
|
||||
format: int64
|
||||
type: integer
|
||||
selector:
|
||||
description: A label selector is a label query over a set of resources.
|
||||
The result of matchLabels and matchExpressions are ANDed. An empty
|
||||
label selector matches all objects. A null label selector matches
|
||||
no objects.
|
||||
properties:
|
||||
matchExpressions:
|
||||
description: matchExpressions is a list of label selector requirements.
|
||||
The requirements are ANDed.
|
||||
items:
|
||||
description: A label selector requirement is a selector that contains
|
||||
values, a key, and an operator that relates the key and values.
|
||||
properties:
|
||||
key:
|
||||
description: key is the label key that the selector applies
|
||||
to.
|
||||
type: string
|
||||
operator:
|
||||
description: operator represents a key's relationship to a
|
||||
set of values. Valid operators are In, NotIn, Exists and
|
||||
DoesNotExist.
|
||||
type: string
|
||||
values:
|
||||
description: values is an array of string values. If the operator
|
||||
is In or NotIn, the values array must be non-empty. If the
|
||||
operator is Exists or DoesNotExist, the values array must
|
||||
be empty. This array is replaced during a strategic merge
|
||||
patch.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- key
|
||||
- operator
|
||||
type: object
|
||||
type: array
|
||||
matchLabels:
|
||||
description: matchLabels is a map of {key,value} pairs. A single
|
||||
{key,value} in the matchLabels map is equivalent to an element
|
||||
of matchExpressions, whose key field is "key", the operator is
|
||||
"In", and the values array contains only "value". The requirements
|
||||
are ANDed.
|
||||
type: object
|
||||
type: object
|
||||
required:
|
||||
- podMetricsEndpoints
|
||||
- selector
|
||||
type: object
|
||||
type: object
|
||||
version: v1
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,250 @@
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: prometheusrules.monitoring.coreos.com
|
||||
spec:
|
||||
group: monitoring.coreos.com
|
||||
names:
|
||||
kind: PrometheusRule
|
||||
plural: prometheusrules
|
||||
scope: Namespaced
|
||||
validation:
|
||||
openAPIV3Schema:
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation
|
||||
of an object. Servers should convert recognized schemas to the latest
|
||||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this
|
||||
object represents. Servers may infer this from the endpoint the client
|
||||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
metadata:
|
||||
description: ObjectMeta is metadata that all persisted resources must have,
|
||||
which includes all objects users must create.
|
||||
properties:
|
||||
annotations:
|
||||
description: 'Annotations is an unstructured key value map stored with
|
||||
a resource that may be set by external tools to store and retrieve
|
||||
arbitrary metadata. They are not queryable and should be preserved
|
||||
when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations'
|
||||
type: object
|
||||
clusterName:
|
||||
description: The name of the cluster which the object belongs to. This
|
||||
is used to distinguish resources with same name and namespace in different
|
||||
clusters. This field is not set anywhere right now and apiserver is
|
||||
going to ignore it if set in create or update request.
|
||||
type: string
|
||||
creationTimestamp:
|
||||
description: Time is a wrapper around time.Time which supports correct
|
||||
marshaling to YAML and JSON. Wrappers are provided for many of the
|
||||
factory methods that the time package offers.
|
||||
format: date-time
|
||||
type: string
|
||||
deletionGracePeriodSeconds:
|
||||
description: Number of seconds allowed for this object to gracefully
|
||||
terminate before it will be removed from the system. Only set when
|
||||
deletionTimestamp is also set. May only be shortened. Read-only.
|
||||
format: int64
|
||||
type: integer
|
||||
deletionTimestamp:
|
||||
description: Time is a wrapper around time.Time which supports correct
|
||||
marshaling to YAML and JSON. Wrappers are provided for many of the
|
||||
factory methods that the time package offers.
|
||||
format: date-time
|
||||
type: string
|
||||
finalizers:
|
||||
description: Must be empty before the object is deleted from the registry.
|
||||
Each entry is an identifier for the responsible component that will
|
||||
remove the entry from the list. If the deletionTimestamp of the object
|
||||
is non-nil, entries in this list can only be removed.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
generateName:
|
||||
description: |-
|
||||
GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server.
|
||||
|
||||
If this field is specified and the generated name exists, the server will NOT return a 409 - instead, it will either return 201 Created or 500 with Reason ServerTimeout indicating a unique name could not be found in the time allotted, and the client should retry (optionally after the time indicated in the Retry-After header).
|
||||
|
||||
Applied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency
|
||||
type: string
|
||||
generation:
|
||||
description: A sequence number representing a specific generation of
|
||||
the desired state. Populated by the system. Read-only.
|
||||
format: int64
|
||||
type: integer
|
||||
labels:
|
||||
description: 'Map of string keys and values that can be used to organize
|
||||
and categorize (scope and select) objects. May match selectors of
|
||||
replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels'
|
||||
type: object
|
||||
managedFields:
|
||||
description: ManagedFields maps workflow-id and version to the set of
|
||||
fields that are managed by that workflow. This is mostly for internal
|
||||
housekeeping, and users typically shouldn't need to set or understand
|
||||
this field. A workflow can be the user's name, a controller's name,
|
||||
or the name of a specific apply path like "ci-cd". The set of fields
|
||||
is always in the version that the workflow used when modifying the
|
||||
object.
|
||||
items:
|
||||
description: ManagedFieldsEntry is a workflow-id, a FieldSet and the
|
||||
group version of the resource that the fieldset applies to.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: APIVersion defines the version of this resource that
|
||||
this field set applies to. The format is "group/version" just
|
||||
like the top-level APIVersion field. It is necessary to track
|
||||
the version of a field set because it cannot be automatically
|
||||
converted.
|
||||
type: string
|
||||
fieldsType:
|
||||
description: 'FieldsType is the discriminator for the different
|
||||
fields format and version. There is currently only one possible
|
||||
value: "FieldsV1"'
|
||||
type: string
|
||||
fieldsV1:
|
||||
description: |-
|
||||
FieldsV1 stores a set of fields in a data structure like a Trie, in JSON format.
|
||||
|
||||
Each key is either a '.' representing the field itself, and will always map to an empty set, or a string representing a sub-field or item. The string will follow one of these four formats: 'f:<name>', where <name> is the name of a field in a struct, or key in a map 'v:<value>', where <value> is the exact json formatted value of a list item 'i:<index>', where <index> is position of a item in a list 'k:<keys>', where <keys> is a map of a list item's key fields to their unique values If a key maps to an empty Fields value, the field that key represents is part of the set.
|
||||
|
||||
The exact format is defined in sigs.k8s.io/structured-merge-diff
|
||||
type: object
|
||||
manager:
|
||||
description: Manager is an identifier of the workflow managing
|
||||
these fields.
|
||||
type: string
|
||||
operation:
|
||||
description: Operation is the type of operation which lead to
|
||||
this ManagedFieldsEntry being created. The only valid values
|
||||
for this field are 'Apply' and 'Update'.
|
||||
type: string
|
||||
time:
|
||||
description: Time is a wrapper around time.Time which supports
|
||||
correct marshaling to YAML and JSON. Wrappers are provided
|
||||
for many of the factory methods that the time package offers.
|
||||
format: date-time
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
name:
|
||||
description: 'Name must be unique within a namespace. Is required when
|
||||
creating resources, although some resources may allow a client to
|
||||
request the generation of an appropriate name automatically. Name
|
||||
is primarily intended for creation idempotence and configuration definition.
|
||||
Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names'
|
||||
type: string
|
||||
namespace:
|
||||
description: |-
|
||||
Namespace defines the space within each name must be unique. An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.
|
||||
|
||||
Must be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces
|
||||
type: string
|
||||
ownerReferences:
|
||||
description: List of objects depended by this object. If ALL objects
|
||||
in the list have been deleted, this object will be garbage collected.
|
||||
If this object is managed by a controller, then an entry in this list
|
||||
will point to this controller, with the controller field set to true.
|
||||
There cannot be more than one managing controller.
|
||||
items:
|
||||
description: OwnerReference contains enough information to let you
|
||||
identify an owning object. An owning object must be in the same
|
||||
namespace as the dependent, or be cluster-scoped, so there is no
|
||||
namespace field.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: API version of the referent.
|
||||
type: string
|
||||
blockOwnerDeletion:
|
||||
description: If true, AND if the owner has the "foregroundDeletion"
|
||||
finalizer, then the owner cannot be deleted from the key-value
|
||||
store until this reference is removed. Defaults to false. To
|
||||
set this field, a user needs "delete" permission of the owner,
|
||||
otherwise 422 (Unprocessable Entity) will be returned.
|
||||
type: boolean
|
||||
controller:
|
||||
description: If true, this reference points to the managing controller.
|
||||
type: boolean
|
||||
kind:
|
||||
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names'
|
||||
type: string
|
||||
uid:
|
||||
description: 'UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids'
|
||||
type: string
|
||||
required:
|
||||
- apiVersion
|
||||
- kind
|
||||
- name
|
||||
- uid
|
||||
type: object
|
||||
type: array
|
||||
resourceVersion:
|
||||
description: |-
|
||||
An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources.
|
||||
|
||||
Populated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
|
||||
type: string
|
||||
selfLink:
|
||||
description: |-
|
||||
SelfLink is a URL representing this object. Populated by the system. Read-only.
|
||||
|
||||
DEPRECATED Kubernetes will stop propagating this field in 1.20 release and the field is planned to be removed in 1.21 release.
|
||||
type: string
|
||||
uid:
|
||||
description: |-
|
||||
UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations.
|
||||
|
||||
Populated by the system. Read-only. More info: http://kubernetes.io/docs/user-guide/identifiers#uids
|
||||
type: string
|
||||
type: object
|
||||
spec:
|
||||
description: PrometheusRuleSpec contains specification parameters for a
|
||||
Rule.
|
||||
properties:
|
||||
groups:
|
||||
description: Content of Prometheus rule file
|
||||
items:
|
||||
description: RuleGroup is a list of sequentially evaluated recording
|
||||
and alerting rules.
|
||||
properties:
|
||||
interval:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
rules:
|
||||
items:
|
||||
description: Rule describes an alerting or recording rule.
|
||||
properties:
|
||||
alert:
|
||||
type: string
|
||||
annotations:
|
||||
type: object
|
||||
expr:
|
||||
anyOf:
|
||||
- type: string
|
||||
- type: integer
|
||||
for:
|
||||
type: string
|
||||
labels:
|
||||
type: object
|
||||
record:
|
||||
type: string
|
||||
required:
|
||||
- expr
|
||||
type: object
|
||||
type: array
|
||||
required:
|
||||
- name
|
||||
- rules
|
||||
type: object
|
||||
type: array
|
||||
type: object
|
||||
type: object
|
||||
version: v1
|
@ -0,0 +1,346 @@
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: servicemonitors.monitoring.coreos.com
|
||||
spec:
|
||||
group: monitoring.coreos.com
|
||||
names:
|
||||
kind: ServiceMonitor
|
||||
plural: servicemonitors
|
||||
scope: Namespaced
|
||||
validation:
|
||||
openAPIV3Schema:
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation
|
||||
of an object. Servers should convert recognized schemas to the latest
|
||||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
|
||||
type: string
|
||||
kind:
|
||||
description: 'Kind is a string value representing the REST resource this
|
||||
object represents. Servers may infer this from the endpoint the client
|
||||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
|
||||
type: string
|
||||
spec:
|
||||
description: ServiceMonitorSpec contains specification parameters for a
|
||||
ServiceMonitor.
|
||||
properties:
|
||||
endpoints:
|
||||
description: A list of endpoints allowed as part of this ServiceMonitor.
|
||||
items:
|
||||
description: Endpoint defines a scrapeable endpoint serving Prometheus
|
||||
metrics.
|
||||
properties:
|
||||
basicAuth:
|
||||
description: 'BasicAuth allow an endpoint to authenticate over
|
||||
basic authentication More info: https://prometheus.io/docs/operating/configuration/#endpoints'
|
||||
properties:
|
||||
password:
|
||||
description: SecretKeySelector selects a key of a Secret.
|
||||
properties:
|
||||
key:
|
||||
description: The key of the secret to select from. Must
|
||||
be a valid secret key.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the Secret or its key must
|
||||
be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
username:
|
||||
description: SecretKeySelector selects a key of a Secret.
|
||||
properties:
|
||||
key:
|
||||
description: The key of the secret to select from. Must
|
||||
be a valid secret key.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the Secret or its key must
|
||||
be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
type: object
|
||||
bearerTokenFile:
|
||||
description: File to read bearer token for scraping targets.
|
||||
type: string
|
||||
bearerTokenSecret:
|
||||
description: SecretKeySelector selects a key of a Secret.
|
||||
properties:
|
||||
key:
|
||||
description: The key of the secret to select from. Must be
|
||||
a valid secret key.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the Secret or its key must be
|
||||
defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
honorLabels:
|
||||
description: HonorLabels chooses the metric's labels on collisions
|
||||
with target labels.
|
||||
type: boolean
|
||||
honorTimestamps:
|
||||
description: HonorTimestamps controls whether Prometheus respects
|
||||
the timestamps present in scraped data.
|
||||
type: boolean
|
||||
interval:
|
||||
description: Interval at which metrics should be scraped
|
||||
type: string
|
||||
metricRelabelings:
|
||||
description: MetricRelabelConfigs to apply to samples before ingestion.
|
||||
items:
|
||||
description: 'RelabelConfig allows dynamic rewriting of the
|
||||
label set, being applied to samples before ingestion. It defines
|
||||
`<metric_relabel_configs>`-section of Prometheus configuration.
|
||||
More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs'
|
||||
properties:
|
||||
action:
|
||||
description: Action to perform based on regex matching.
|
||||
Default is 'replace'
|
||||
type: string
|
||||
modulus:
|
||||
description: Modulus to take of the hash of the source label
|
||||
values.
|
||||
format: int64
|
||||
type: integer
|
||||
regex:
|
||||
description: Regular expression against which the extracted
|
||||
value is matched. defailt is '(.*)'
|
||||
type: string
|
||||
replacement:
|
||||
description: Replacement value against which a regex replace
|
||||
is performed if the regular expression matches. Regex
|
||||
capture groups are available. Default is '$1'
|
||||
type: string
|
||||
separator:
|
||||
description: Separator placed between concatenated source
|
||||
label values. default is ';'.
|
||||
type: string
|
||||
sourceLabels:
|
||||
description: The source labels select values from existing
|
||||
labels. Their content is concatenated using the configured
|
||||
separator and matched against the configured regular expression
|
||||
for the replace, keep, and drop actions.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
targetLabel:
|
||||
description: Label to which the resulting value is written
|
||||
in a replace action. It is mandatory for replace actions.
|
||||
Regex capture groups are available.
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
params:
|
||||
description: Optional HTTP URL parameters
|
||||
type: object
|
||||
path:
|
||||
description: HTTP path to scrape for metrics.
|
||||
type: string
|
||||
port:
|
||||
description: Name of the service port this endpoint refers to.
|
||||
Mutually exclusive with targetPort.
|
||||
type: string
|
||||
proxyUrl:
|
||||
description: ProxyURL eg http://proxyserver:2195 Directs scrapes
|
||||
to proxy through this endpoint.
|
||||
type: string
|
||||
relabelings:
|
||||
description: 'RelabelConfigs to apply to samples before scraping.
|
||||
More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config'
|
||||
items:
|
||||
description: 'RelabelConfig allows dynamic rewriting of the
|
||||
label set, being applied to samples before ingestion. It defines
|
||||
`<metric_relabel_configs>`-section of Prometheus configuration.
|
||||
More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs'
|
||||
properties:
|
||||
action:
|
||||
description: Action to perform based on regex matching.
|
||||
Default is 'replace'
|
||||
type: string
|
||||
modulus:
|
||||
description: Modulus to take of the hash of the source label
|
||||
values.
|
||||
format: int64
|
||||
type: integer
|
||||
regex:
|
||||
description: Regular expression against which the extracted
|
||||
value is matched. defailt is '(.*)'
|
||||
type: string
|
||||
replacement:
|
||||
description: Replacement value against which a regex replace
|
||||
is performed if the regular expression matches. Regex
|
||||
capture groups are available. Default is '$1'
|
||||
type: string
|
||||
separator:
|
||||
description: Separator placed between concatenated source
|
||||
label values. default is ';'.
|
||||
type: string
|
||||
sourceLabels:
|
||||
description: The source labels select values from existing
|
||||
labels. Their content is concatenated using the configured
|
||||
separator and matched against the configured regular expression
|
||||
for the replace, keep, and drop actions.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
targetLabel:
|
||||
description: Label to which the resulting value is written
|
||||
in a replace action. It is mandatory for replace actions.
|
||||
Regex capture groups are available.
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
scheme:
|
||||
description: HTTP scheme to use for scraping.
|
||||
type: string
|
||||
scrapeTimeout:
|
||||
description: Timeout after which the scrape is ended
|
||||
type: string
|
||||
targetPort:
|
||||
anyOf:
|
||||
- type: string
|
||||
- type: integer
|
||||
tlsConfig:
|
||||
description: TLSConfig specifies TLS configuration parameters.
|
||||
properties:
|
||||
ca: {}
|
||||
caFile:
|
||||
description: Path to the CA cert in the Prometheus container
|
||||
to use for the targets.
|
||||
type: string
|
||||
cert: {}
|
||||
certFile:
|
||||
description: Path to the client cert file in the Prometheus
|
||||
container for the targets.
|
||||
type: string
|
||||
insecureSkipVerify:
|
||||
description: Disable target certificate validation.
|
||||
type: boolean
|
||||
keyFile:
|
||||
description: Path to the client key file in the Prometheus
|
||||
container for the targets.
|
||||
type: string
|
||||
keySecret:
|
||||
description: SecretKeySelector selects a key of a Secret.
|
||||
properties:
|
||||
key:
|
||||
description: The key of the secret to select from. Must
|
||||
be a valid secret key.
|
||||
type: string
|
||||
name:
|
||||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
|
||||
type: string
|
||||
optional:
|
||||
description: Specify whether the Secret or its key must
|
||||
be defined
|
||||
type: boolean
|
||||
required:
|
||||
- key
|
||||
type: object
|
||||
serverName:
|
||||
description: Used to verify the hostname for the targets.
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
type: array
|
||||
jobLabel:
|
||||
description: The label to use to retrieve the job name from.
|
||||
type: string
|
||||
namespaceSelector:
|
||||
description: NamespaceSelector is a selector for selecting either all
|
||||
namespaces or a list of namespaces.
|
||||
properties:
|
||||
any:
|
||||
description: Boolean describing whether all namespaces are selected
|
||||
in contrast to a list restricting them.
|
||||
type: boolean
|
||||
matchNames:
|
||||
description: List of namespace names.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
podTargetLabels:
|
||||
description: PodTargetLabels transfers labels on the Kubernetes Pod
|
||||
onto the target.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
sampleLimit:
|
||||
description: SampleLimit defines per-scrape limit on number of scraped
|
||||
samples that will be accepted.
|
||||
format: int64
|
||||
type: integer
|
||||
selector:
|
||||
description: A label selector is a label query over a set of resources.
|
||||
The result of matchLabels and matchExpressions are ANDed. An empty
|
||||
label selector matches all objects. A null label selector matches
|
||||
no objects.
|
||||
properties:
|
||||
matchExpressions:
|
||||
description: matchExpressions is a list of label selector requirements.
|
||||
The requirements are ANDed.
|
||||
items:
|
||||
description: A label selector requirement is a selector that contains
|
||||
values, a key, and an operator that relates the key and values.
|
||||
properties:
|
||||
key:
|
||||
description: key is the label key that the selector applies
|
||||
to.
|
||||
type: string
|
||||
operator:
|
||||
description: operator represents a key's relationship to a
|
||||
set of values. Valid operators are In, NotIn, Exists and
|
||||
DoesNotExist.
|
||||
type: string
|
||||
values:
|
||||
description: values is an array of string values. If the operator
|
||||
is In or NotIn, the values array must be non-empty. If the
|
||||
operator is Exists or DoesNotExist, the values array must
|
||||
be empty. This array is replaced during a strategic merge
|
||||
patch.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- key
|
||||
- operator
|
||||
type: object
|
||||
type: array
|
||||
matchLabels:
|
||||
description: matchLabels is a map of {key,value} pairs. A single
|
||||
{key,value} in the matchLabels map is equivalent to an element
|
||||
of matchExpressions, whose key field is "key", the operator is
|
||||
"In", and the values array contains only "value". The requirements
|
||||
are ANDed.
|
||||
type: object
|
||||
type: object
|
||||
targetLabels:
|
||||
description: TargetLabels transfers labels on the Kubernetes Service
|
||||
onto the target.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- endpoints
|
||||
- selector
|
||||
type: object
|
||||
type: object
|
||||
version: v1
|
@ -0,0 +1,48 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: controller
|
||||
app.kubernetes.io/name: prometheus-operator
|
||||
app.kubernetes.io/version: v0.34.0
|
||||
name: prometheus-operator
|
||||
namespace: monitoring
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: controller
|
||||
app.kubernetes.io/name: prometheus-operator
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: controller
|
||||
app.kubernetes.io/name: prometheus-operator
|
||||
app.kubernetes.io/version: v0.34.0
|
||||
spec:
|
||||
containers:
|
||||
- args:
|
||||
- --kubelet-service=kube-system/kubelet
|
||||
- --logtostderr=true
|
||||
- --config-reloader-image=quay.io/coreos/configmap-reload:v0.0.1
|
||||
- --prometheus-config-reloader=quay.io/coreos/prometheus-config-reloader:v0.34.0
|
||||
image: quay.io/coreos/prometheus-operator:v0.34.0
|
||||
name: prometheus-operator
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
name: http
|
||||
resources:
|
||||
limits:
|
||||
cpu: 200m
|
||||
memory: 200Mi
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
nodeSelector:
|
||||
beta.kubernetes.io/os: linux
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
serviceAccountName: prometheus-operator
|
@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: monitoring
|
@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: controller
|
||||
app.kubernetes.io/name: prometheus-operator
|
||||
app.kubernetes.io/version: v0.34.0
|
||||
name: prometheus-operator
|
||||
namespace: monitoring
|
@ -0,0 +1,18 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: controller
|
||||
app.kubernetes.io/name: prometheus-operator
|
||||
app.kubernetes.io/version: v0.34.0
|
||||
name: prometheus-operator
|
||||
namespace: monitoring
|
||||
spec:
|
||||
clusterIP: None
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
targetPort: http
|
||||
selector:
|
||||
app.kubernetes.io/component: controller
|
||||
app.kubernetes.io/name: prometheus-operator
|
38
prometheus-monitoring/kubernetes/1.15-1.17/readme.md
Normal file
38
prometheus-monitoring/kubernetes/1.15-1.17/readme.md
Normal file
@ -0,0 +1,38 @@
|
||||
# Kubernetes 1.15-1.17 Monitoring Guide
|
||||
|
||||
Create a cluster with [kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
|
||||
```
|
||||
|
||||
# Kubernetes 1.16.9
|
||||
kind create cluster --name prometheus --image kindest/node:v1.16.9
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
kubectl create ns monitoring
|
||||
|
||||
# Create the operator to instanciate all CRDs
|
||||
kubectl -n monitoring apply -f ./prometheus-monitoring/kubernetes/1.15-1.17/prometheus-operator/
|
||||
|
||||
# Deploy monitoring components
|
||||
kubectl -n monitoring apply -f ./prometheus-monitoring/kubernetes/1.15-1.17/node-exporter/
|
||||
kubectl -n monitoring apply -f ./prometheus-monitoring/kubernetes/1.15-1.17/kube-state-metrics/
|
||||
kubectl -n monitoring apply -f ./prometheus-monitoring/kubernetes/1.15-1.17/alertmanager
|
||||
|
||||
# Deploy prometheus instance and all the service monitors for targets
|
||||
kubectl -n monitoring apply -f ./prometheus-monitoring/kubernetes/1.15-1.17/prometheus-cluster-monitoring/
|
||||
|
||||
# Dashboarding
|
||||
kubectl -n monitoring create -f ./prometheus-monitoring/kubernetes/1.15-1.17/grafana/
|
||||
|
||||
# Check the pods
|
||||
kubectl -n monitoring get pods
|
||||
|
||||
# Note : Metrics can take couple of minutes to ingest!
|
||||
|
||||
# Test target connectivity
|
||||
kubectl -n monitoring port-forward prometheus-k8s-0 9090
|
||||
|
||||
# Dashboards
|
||||
kubectl -n monitoring port-forward <grafana-pod-name> 3000
|
||||
```
|
@ -1,6 +1,7 @@
|
||||
# Kubernetes monitoring with Prometheus
|
||||
|
||||
Kubernetes [1.14.8](./1.14.8/readme.md) <br/>
|
||||
Kubernetes [1.15-1.17](./1.15-1.17/readme.md) <br/>
|
||||
Kubernetes [1.18.4](./1.18.4/readme.md) <br/>
|
||||
|
||||
## Prometheus Overview
|
||||
|
66
storage/redis/applications/client/client.go
Normal file
66
storage/redis/applications/client/client.go
Normal file
@ -0,0 +1,66 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"context"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var redis_host = os.Getenv("REDIS_HOST")
|
||||
var redis_port = os.Getenv("REDIS_PORT")
|
||||
var redis_password = os.Getenv("REDIS_PASSWORD")
|
||||
|
||||
var ctx = context.Background()
|
||||
var rdb *redis.Client
|
||||
|
||||
var counter = 0
|
||||
func main() {
|
||||
|
||||
r := redis.NewClient(&redis.Options{
|
||||
Addr: redis_host + ":" + redis_port,
|
||||
Password: redis_password, // no password set
|
||||
DB: 0, // use default DB
|
||||
})
|
||||
rdb = r
|
||||
|
||||
router := httprouter.New()
|
||||
|
||||
router.GET("/", func(w http.ResponseWriter, r *http.Request, p httprouter.Params){
|
||||
increment_redis_key(w,r,p)
|
||||
})
|
||||
|
||||
fmt.Println("Running...")
|
||||
log.Fatal(http.ListenAndServe(":80", router))
|
||||
}
|
||||
|
||||
func increment_redis_key(writer http.ResponseWriter, request *http.Request, p httprouter.Params) {
|
||||
|
||||
val, err := rdb.Get(ctx, "counter").Result()
|
||||
|
||||
if err == redis.Nil {
|
||||
err := rdb.Set(ctx, "counter", 1, 0).Err()
|
||||
counter++
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
} else if err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
counter,_ = strconv.Atoi(val)
|
||||
counter++
|
||||
err := rdb.Set(ctx, "counter", counter, 0).Err()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprint(writer, counter)
|
||||
fmt.Println("counter", counter)
|
||||
}
|
17
storage/redis/applications/client/dockerfile
Normal file
17
storage/redis/applications/client/dockerfile
Normal file
@ -0,0 +1,17 @@
|
||||
FROM golang:1.14-alpine as build
|
||||
|
||||
RUN apk add --no-cache git
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY go.sum /src/
|
||||
COPY go.mod /src/
|
||||
|
||||
COPY client.go /src
|
||||
|
||||
RUN go build client.go
|
||||
|
||||
FROM alpine as runtime
|
||||
|
||||
COPY --from=build /src/client /app/client
|
||||
CMD [ "/app/client" ]
|
9
storage/redis/applications/client/go.mod
Normal file
9
storage/redis/applications/client/go.mod
Normal file
@ -0,0 +1,9 @@
|
||||
module example.com/hello
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/go-redis/redis/v8 v8.0.0-beta.7 // indirect
|
||||
github.com/julienschmidt/httprouter v1.3.0 // indirect
|
||||
github.com/sirupsen/logrus v1.6.0 // indirect
|
||||
)
|
130
storage/redis/applications/client/go.sum
Normal file
130
storage/redis/applications/client/go.sum
Normal file
@ -0,0 +1,130 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60=
|
||||
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200624174652-8d2f3be8b2d9 h1:h2Ul3Ym2iVZWMQGYmulVUJ4LSkBm1erp9mUkPwtMoLg=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200624174652-8d2f3be8b2d9/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-redis/redis v6.15.8+incompatible h1:BKZuG6mCnRj5AOaWJXoCgf6rqTYnYJLe4en2hxT7r9o=
|
||||
github.com/go-redis/redis/v8 v8.0.0-beta.7 h1:4HiY+qfsyz8OUr9zyAP2T1CJ0SFRY4mKFvm9TEznuv8=
|
||||
github.com/go-redis/redis/v8 v8.0.0-beta.7/go.mod h1:FGJAWDWFht1sQ4qxyJHZZbVyvnVcKQN0E3u5/5lRz+g=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
go.opentelemetry.io/otel v0.7.0 h1:u43jukpwqR8EsyeJOMgrsUgZwVI1e1eVw7yuzRkD1l0=
|
||||
go.opentelemetry.io/otel v0.7.0/go.mod h1:aZMyHG5TqDOXEgH2tyLiXSUKly1jT3yqE9PmrzIeCdo=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20200513190911-00229845015e h1:rMqLP+9XLy+LdbCXHjJHAmTfXCr93W7oruWA6Hq1Alc=
|
||||
golang.org/x/exp v0.0.0-20200513190911-00229845015e/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE=
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
158
storage/redis/clustering/readme.md
Normal file
158
storage/redis/clustering/readme.md
Normal file
@ -0,0 +1,158 @@
|
||||
|
||||
## Replication
|
||||
|
||||
Documentation [here](https://redis.io/topics/replication)
|
||||
|
||||
### Configuration
|
||||
|
||||
```
|
||||
#persistence
|
||||
dir /data
|
||||
dbfilename dump.rdb
|
||||
appendonly yes
|
||||
appendfilename "appendonly.aof"
|
||||
|
||||
```
|
||||
### redis-0 Configuration
|
||||
|
||||
```
|
||||
protected-mode no
|
||||
port 6379
|
||||
|
||||
#authentication
|
||||
masterauth a-very-complex-password-here
|
||||
requirepass a-very-complex-password-here
|
||||
```
|
||||
### redis-1 Configuration
|
||||
|
||||
```
|
||||
protected-mode no
|
||||
port 6379
|
||||
slaveof redis-0 6379
|
||||
|
||||
#authentication
|
||||
masterauth a-very-complex-password-here
|
||||
requirepass a-very-complex-password-here
|
||||
|
||||
```
|
||||
### redis-2 Configuration
|
||||
|
||||
```
|
||||
protected-mode no
|
||||
port 6379
|
||||
slaveof redis-0 6379
|
||||
|
||||
#authentication
|
||||
masterauth a-very-complex-password-here
|
||||
requirepass a-very-complex-password-here
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
# remember to update above in configs!
|
||||
|
||||
docker network create redis
|
||||
|
||||
cd .\storage\redis\clustering\
|
||||
|
||||
#redis-0
|
||||
docker run -d --rm --name redis-0 `
|
||||
--net redis `
|
||||
-v ${PWD}/redis-0:/etc/redis/ `
|
||||
redis:6.0-alpine redis-server /etc/redis/redis.conf
|
||||
|
||||
#redis-1
|
||||
docker run -d --rm --name redis-1 `
|
||||
--net redis `
|
||||
-v ${PWD}/redis-1:/etc/redis/ `
|
||||
redis:6.0-alpine redis-server /etc/redis/redis.conf
|
||||
|
||||
|
||||
#redis-2
|
||||
docker run -d --rm --name redis-2 `
|
||||
--net redis `
|
||||
-v ${PWD}/redis-2:/etc/redis/ `
|
||||
redis:6.0-alpine redis-server /etc/redis/redis.conf
|
||||
|
||||
```
|
||||
|
||||
## Example Application
|
||||
|
||||
Run example application in video, to show application writing to the master
|
||||
|
||||
```
|
||||
cd .\storage\redis\applications\client\
|
||||
docker build . -t aimvector/redis-client:v1.0.0
|
||||
|
||||
docker run -it --net redis `
|
||||
-e REDIS_HOST=redis-0 `
|
||||
-e REDIS_PORT=6379 `
|
||||
-e REDIS_PASSWORD="a-very-complex-password-here" `
|
||||
-p 80:80 `
|
||||
aimvector/redis-client:v1.0.0
|
||||
|
||||
```
|
||||
|
||||
## Test Replication
|
||||
|
||||
Technically written data should now be on the replicas
|
||||
|
||||
```
|
||||
# go to one of the clients
|
||||
docker exec -it redis-2 sh
|
||||
redis-cli
|
||||
auth "a-very-complex-password-here"
|
||||
keys *
|
||||
|
||||
```
|
||||
|
||||
## Running Sentinels
|
||||
|
||||
Documentation [here](https://redis.io/topics/sentinel)
|
||||
|
||||
```
|
||||
#********BASIC CONFIG************************************
|
||||
port 5000
|
||||
sentinel monitor mymaster redis-0 6379 2
|
||||
sentinel down-after-milliseconds mymaster 5000
|
||||
sentinel failover-timeout mymaster 60000
|
||||
sentinel parallel-syncs mymaster 1
|
||||
sentinel auth-pass mymaster a-very-complex-password-here
|
||||
#********************************************
|
||||
|
||||
```
|
||||
Starting Redis in sentinel mode
|
||||
|
||||
```
|
||||
cd .\storage\redis\clustering\
|
||||
|
||||
docker run -d --rm --name sentinel-0 --net redis `
|
||||
-v ${PWD}/sentinel-0:/etc/redis/ `
|
||||
redis:6.0-alpine `
|
||||
redis-sentinel /etc/redis/sentinel.conf
|
||||
|
||||
docker run -d --rm --name sentinel-1 --net redis `
|
||||
-v ${PWD}/sentinel-1:/etc/redis/ `
|
||||
redis:6.0-alpine `
|
||||
redis-sentinel /etc/redis/sentinel.conf
|
||||
|
||||
docker run -d --rm --name sentinel-2 --net redis `
|
||||
-v ${PWD}/sentinel-2:/etc/redis/ `
|
||||
redis:6.0-alpine `
|
||||
redis-sentinel /etc/redis/sentinel.conf
|
||||
|
||||
|
||||
docker logs sentinel-0
|
||||
docker exec -it sentinel-0 sh
|
||||
redis-cli -p 5000
|
||||
info
|
||||
sentinel master mymaster
|
||||
|
||||
# clean up
|
||||
|
||||
docker rm -f redis-0 redis-1 redis-2
|
||||
docker rm -f sentinel-0 sentinel-1 sentinel-2
|
||||
|
||||
|
||||
```
|
1834
storage/redis/clustering/redis-0/redis.conf
Normal file
1834
storage/redis/clustering/redis-0/redis.conf
Normal file
File diff suppressed because it is too large
Load Diff
1834
storage/redis/clustering/redis-1/redis.conf
Normal file
1834
storage/redis/clustering/redis-1/redis.conf
Normal file
File diff suppressed because it is too large
Load Diff
1834
storage/redis/clustering/redis-2/redis.conf
Normal file
1834
storage/redis/clustering/redis-2/redis.conf
Normal file
File diff suppressed because it is too large
Load Diff
6
storage/redis/clustering/sentinel-0/sentinel.conf
Normal file
6
storage/redis/clustering/sentinel-0/sentinel.conf
Normal file
@ -0,0 +1,6 @@
|
||||
port 5000
|
||||
sentinel monitor mymaster redis-0 6379 2
|
||||
sentinel down-after-milliseconds mymaster 5000
|
||||
sentinel failover-timeout mymaster 60000
|
||||
sentinel parallel-syncs mymaster 1
|
||||
sentinel auth-pass mymaster a-very-complex-password-here
|
6
storage/redis/clustering/sentinel-1/sentinel.conf
Normal file
6
storage/redis/clustering/sentinel-1/sentinel.conf
Normal file
@ -0,0 +1,6 @@
|
||||
port 5000
|
||||
sentinel monitor mymaster redis-0 6379 2
|
||||
sentinel down-after-milliseconds mymaster 5000
|
||||
sentinel failover-timeout mymaster 60000
|
||||
sentinel parallel-syncs mymaster 1
|
||||
sentinel auth-pass mymaster a-very-complex-password-here
|
6
storage/redis/clustering/sentinel-2/sentinel.conf
Normal file
6
storage/redis/clustering/sentinel-2/sentinel.conf
Normal file
@ -0,0 +1,6 @@
|
||||
port 5000
|
||||
sentinel monitor mymaster redis-0 6379 2
|
||||
sentinel down-after-milliseconds mymaster 5000
|
||||
sentinel failover-timeout mymaster 60000
|
||||
sentinel parallel-syncs mymaster 1
|
||||
sentinel auth-pass mymaster a-very-complex-password-here
|
1832
storage/redis/config/redis.conf
Normal file
1832
storage/redis/config/redis.conf
Normal file
File diff suppressed because it is too large
Load Diff
84
storage/redis/readme.md
Normal file
84
storage/redis/readme.md
Normal file
@ -0,0 +1,84 @@
|
||||
# Redis
|
||||
|
||||
## Docker
|
||||
|
||||
Docker image over [here](https://hub.docker.com/_/redis)
|
||||
|
||||
## Running redis
|
||||
|
||||
```
|
||||
docker network create redis
|
||||
docker run -it --rm --name redis --net redis -p 6379:6379 redis:6.0-alpine
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Redis configuration documentation [here](https://redis.io/topics/config)
|
||||
|
||||
Starting Redis with a custom config
|
||||
|
||||
```
|
||||
cd .\storage\redis\
|
||||
docker run -it --rm --name redis --net redis -v ${PWD}/config:/etc/redis/ redis:6.0-alpine redis-server /etc/redis/redis.conf
|
||||
|
||||
```
|
||||
|
||||
## Security
|
||||
|
||||
Redis should not be exposed to public.
|
||||
Always use a strong password in `redis.conf`
|
||||
|
||||
```
|
||||
requirepass SuperSecretSecureStrongPass
|
||||
```
|
||||
|
||||
|
||||
## Persistence
|
||||
|
||||
Redis Persistence Documentation [here](https://redis.io/topics/persistence)
|
||||
|
||||
```
|
||||
docker volume create redis
|
||||
cd .\storage\redis\
|
||||
docker run -it --rm --name redis --net redis -v ${PWD}/config:/etc/redis/ -v redis:/data/ redis:6.0-alpine redis-server /etc/redis/redis.conf
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Redis client application
|
||||
|
||||
An example application that reads a key from Redis, increments it and writes it back to Redis.
|
||||
|
||||
```
|
||||
cd .\storage\redis\applications\client\
|
||||
|
||||
# start go dev environment
|
||||
docker run -it -v ${PWD}:/go/src -w /go/src --net redis -p 80:80 golang:1.14-alpine
|
||||
|
||||
go build client.go
|
||||
# start the app
|
||||
./client
|
||||
|
||||
# build the container
|
||||
docker build . -t aimvector/redis-client:v1.0.0
|
||||
|
||||
```
|
||||
|
||||
Run our application
|
||||
|
||||
```
|
||||
cd .\storage\redis\applications\client\
|
||||
docker build . -t aimvector/redis-client:v1.0.0
|
||||
|
||||
docker run -it --net redis `
|
||||
-e REDIS_HOST=redis `
|
||||
-e REDIS_PORT=6379 `
|
||||
-e REDIS_PASSWORD="SuperSecretSecureStrongPass" `
|
||||
-p 80:80 `
|
||||
aimvector/redis-client:v1.0.0
|
||||
|
||||
```
|
||||
|
||||
## Redis Replication and High Availability
|
||||
|
||||
Lets move on to the [clustering](./clustering/readme.md) secion.
|
Loading…
x
Reference in New Issue
Block a user