Skip to content

Commit

Permalink
creating new folders
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmarceleza committed Oct 14, 2022
1 parent a543463 commit 37a5044
Show file tree
Hide file tree
Showing 14 changed files with 914 additions and 90 deletions.
90 changes: 90 additions & 0 deletions configmap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Configmap

## 01 - Variáveis de ambiente

```
apiVersion: v1
kind: Pod
metadata:
name: envar-demo
labels:
purpose: demonstrate-envars
spec:
containers:
- name: envar-demo-container
image: gcr.io/google-samples/node-hello:1.0
env:
- name: DEMO_GREETING
value: "Hello from the environment"
- name: DEMO_FAREWELL
value: "Such a sweet sorrow"
```

```
kubectl exec -it envar-demo -- env
```

## 02 - ConfigMaps

É um objeto de API usado para armazenamento de informações não confidenciais no padrão de chave valor. Pods podem consumir esses objetos como variáveis de ambiente, argumentos de linha de comando ou como arquivos de configuração em um volume.

```
apiVersion: v1
kind: ConfigMap
metadata:
name: game-demo
data:
# property-like keys; each key maps to a simple value
player_initial_lives: "3"
ui_properties_file_name: "user-interface.properties"
# file-like keys
game.properties: |
enemy.types=aliens,monsters
player.maximum-lives=5
user-interface.properties: |
color.good=purple
color.bad=yellow
allow.textmode=true
```

```
apiVersion: v1
kind: Pod
metadata:
name: configmap-demo-pod
spec:
containers:
- name: demo
image: alpine
command: ["sleep", "3600"]
env:
# Define the environment variable
- name: PLAYER_INITIAL_LIVES # Notice that the case is different here
# from the key name in the ConfigMap.
valueFrom:
configMapKeyRef:
name: game-demo # The ConfigMap this value comes from.
key: player_initial_lives # The key to fetch.
- name: UI_PROPERTIES_FILE_NAME
valueFrom:
configMapKeyRef:
name: game-demo
key: ui_properties_file_name
volumeMounts:
- name: config
mountPath: "/config"
readOnly: true
volumes:
# You set volumes at the Pod level, then mount them into containers inside that Pod
- name: config
configMap:
# Provide the name of the ConfigMap you want to mount.
name: game-demo
# An array of keys from the ConfigMap to create as files
items:
- key: "game.properties"
path: "game.properties"
- key: "user-interface.properties"
path: "user-interface.properties"
```
27 changes: 27 additions & 0 deletions crojob/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Cronjobs

```
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox:1.28
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
```

```
watch kubectl get jobs,pods,cj
```
20 changes: 20 additions & 0 deletions daemonset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Daemonsets

```
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: exemplo-ds
spec:
selector:
matchLabels:
app: exemplo-ds
template:
metadata:
labels:
app: exemplo-ds
spec:
containers:
- image: nginx:alpine
name: nginx
```
90 changes: 0 additions & 90 deletions deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,93 +70,3 @@ Escale o deployment para cinco réplicas:
```
kubectl scale deployment/nginx-deployment --replicas=5
```

#### 02 - HorizontalPodAutoscaler (HPA)

Para utilização do HPA precisaremos instalar o [metrics-server](https://github.com/kubernetes-sigs/metrics-server) no cluster:

```
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
```

Para concluir a instalação, edite o deployment adicionando um campo `--kubelet-insecure-tls` da lista de `args` do container.

Instale o deployment de exemplo abaixo e inspecione os objetos no cluster:

```
apiVersion: apps/v1
kind: Deployment
metadata:
name: hpa-demo-deployment
spec:
selector:
matchLabels:
run: hpa-demo-deployment
replicas: 1
template:
metadata:
labels:
run: hpa-demo-deployment
spec:
containers:
- name: hpa-demo-deployment
image: k8s.gcr.io/hpa-example
ports:
- containerPort: 80
resources:
limits:
cpu: 500m
requests:
cpu: 200m
```

Crie o service no cluster:

```
apiVersion: v1
kind: Service
metadata:
name: hpa-demo-deployment
labels:
run: hpa-demo-deployment
spec:
ports:
- port: 80
selector:
run: hpa-demo-deployment
```

Crie o HPA no cluster:

```
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: hpa-demo-deployment
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: hpa-demo-deployment
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 50
```

Suba um container usando a image busybox para adicionar carga de CPU no pod:

```
kubectl run -i --tty load-generator --rm --image=busybox --restart=Never
```

Dentro do container rode o seguinte comando:

```
while sleep 0.01; do wget -q -O- http://hpa-demo-deployment; done
```

Monitore o HPA e o quantitativo de pods enquanto o comando acima é executado:

```
watch kubectl get pods,hpa
```
89 changes: 89 additions & 0 deletions hpa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# HorizontalPodAutoscaler (HPA)

Para utilização do HPA precisaremos instalar o [metrics-server](https://github.com/kubernetes-sigs/metrics-server) no cluster:

```
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
```

Para concluir a instalação, edite o deployment adicionando um campo `--kubelet-insecure-tls` da lista de `args` do container.

Instale o deployment de exemplo abaixo e inspecione os objetos no cluster:

```
apiVersion: apps/v1
kind: Deployment
metadata:
name: hpa-demo-deployment
spec:
selector:
matchLabels:
run: hpa-demo-deployment
replicas: 1
template:
metadata:
labels:
run: hpa-demo-deployment
spec:
containers:
- name: hpa-demo-deployment
image: k8s.gcr.io/hpa-example
ports:
- containerPort: 80
resources:
limits:
cpu: 500m
requests:
cpu: 200m
```

Crie o service no cluster:

```
apiVersion: v1
kind: Service
metadata:
name: hpa-demo-deployment
labels:
run: hpa-demo-deployment
spec:
ports:
- port: 80
selector:
run: hpa-demo-deployment
```

Crie o HPA no cluster:

```
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: hpa-demo-deployment
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: hpa-demo-deployment
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 50
```

Suba um container usando a image busybox para adicionar carga de CPU no pod:

```
kubectl run -i --tty load-generator --rm --image=busybox --restart=Never
```

Dentro do container rode o seguinte comando:

```
while sleep 0.01; do wget -q -O- http://hpa-demo-deployment; done
```

Monitore o HPA e o quantitativo de pods enquanto o comando acima é executado:

```
watch kubectl get pods,hpa
```
Empty file added ingress/README.md
Empty file.
File renamed without changes.
23 changes: 23 additions & 0 deletions operators/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

# Operators

```
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.21.2/install.sh | bash -s v0.21.2
```

```
kubectl create -f https://operatorhub.io/install/cloud-native-postgresql.yaml
```

```
apiVersion: postgresql.k8s.enterprisedb.io/v1
kind: Cluster
metadata:
name: cluster-sample
spec:
instances: 3
logLevel: info
primaryUpdateStrategy: unsupervised
storage:
size: 1Gi
```
Loading

0 comments on commit 37a5044

Please sign in to comment.