begining to work:
-
Connect to my claster
kub-test in subscriptionce0a8147-e18d-4ad2-b586-e20a2946eb4ххххх
az login
az account set --subscription ce0a8147-e18d-4ad2-b586-e20a2946eb4ххххх
az aks get-credentials --resource-group kub-gp --name kub-test
kubectl get service --all-namespaces
kubectl config get-contexts
az group create --name dops-sandbox --location westeurope
Creat my first service om AKS:
- Creat namespace
-
kind: Namespace apiVersion: v1 metadata: name: dops-sandbox status: phase: Active
-
- Creat DataStore
- kubectl create -f creat_DataStore_postgres.yaml
-
kind: PersistentVolume apiVersion: v1 metadata: name: dops-postgres-pv-volume labels: type: local app: postgres spec: storageClassName: manual capacity: storage: 5Gi accessModes: - ReadWriteMany hostPath: path: "/mnt/data" --- kind: PersistentVolumeClaim apiVersion: v1 metadata: namespace: dops-sandbox name: dops-postgres-pv-claim labels: app: postgres spec: storageClassName: manual accessModes: - ReadWriteMany resources: requests: storage: 5Gi
- Creat configmap
- kubectl create -f postgres-configmap.yaml
-
apiVersion: v1 kind: ConfigMap metadata: name: postgres-config namespace: dops-sandbox labels: app: postgres data: POSTGRES_DB: elg_igor POSTGRES_USER: elg_igor POSTGRES_PASSWORD: admin123
- Creat deployment
- kubectl create -f postgres-deployment.yaml
-
kind: Deployment apiVersion: apps/v1 metadata: name: postgres namespace: dops-sandbox spec: replicas: 1 selector: matchLabels: app: postgres template: metadata: labels: app: postgres spec: containers: - name: postgres image: postgres:10.4 imagePullPolicy: "IfNotPresent" ports: - containerPort: 5432 envFrom: - configMapRef: name: postgres-config volumeMounts: - mountPath: /var/lib/postgresql/data name: postgredb volumes: - name: postgredb persistentVolumeClaim: claimName: dops-postgres-pv-claim
- Creat service
- kubectl create -f postgres-service.yaml
-
apiVersion: v1 kind: Service metadata: name: postgres namespace: dops-sandbox labels: app: postgres spec: type: NodePort ports: - port: 5432 selector: app: postgres
- chek our service
- KPC=`kubectl get pods -l app=postgres -n dops-sandbox | grep Running | grep 1/1 | awk '{print $1}'`
- kubectl exec --stdin --tty $KPC -n dops-sandbox -- /bin/bash
- psql -h localhost -U elg_igor
- Try creat DB and check that data save after reboot pod
- elg_igor=# \l+
- elg_igor=# CREATE DATABASE KSIdb;
- \c KSIdb
- CREATE TABLE tourneys (
name varchar(30),
wins real,
best real,
size real
); - INSERT INTO tourneys (name, wins, best, size)
VALUES ('Dolly', '7', '245', '8.5'),
('Etta', '4', '283', '9'),
('Irma', '9', '266', '7'),
('Barbara', '2', '197', '7.5'),
('Gladys', '13', '273', '8'); - SELECT name FROM tourneys;
- CREATE TABLE tourneys (
- \c KSIdb
- elg_igor=# \l+ And we see that all our data is not :( --so we have to creat Volume with per
- SO DELETE all out lab
- kubectl delete -f postgres-service.yaml
- kubectl delete -f postgres-deployment.yaml
- kubectl delete -f postgres-configmap.yaml
- kubectl delete -f creat_DataStore_postgres.yaml
Creat new sewrvice use new AKS recommendation
Persistent Volume and Persistent Volume Claim
# Get-команды с основном выводом
kubectl get services # Вывести все сервисы в пространстве имён
kubectl get pods --all-namespaces # Вывести все поды во всех пространств имён
kubectl get pods -o wide # Вывести все поды в текущем пространстве имён с подробностями
kubectl get deployment my-dep # Вывести определённое развёртывание
kubectl get pods # Вывести все поды в пространстве имён
kubectl get pod my-pod -o yaml # Получить информацию по поду в формате YAML<