Skip to content

Commit

Permalink
clean labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Sispheor committed Dec 11, 2023
1 parent 0cb3f04 commit b93724b
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 12 deletions.
8 changes: 8 additions & 0 deletions k8s/backup.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# HOW TO RESTORE
# copy backup into django
# kubectl -n squest cp ~/Desktop/db-2023-12-06-182115.dump django-54b69fbb48-wrt9j:/app/backup
# check backup is listed
# kubectl -n squest exec -it django-54b69fbb48-wrt9j python manage.py listbackups
# restore by passing backup file name
# kubectl -n squest exec -it django-54b69fbb48-wrt9j -- python manage.py dbrestore --database default -i db-2023-12-06-182115.dump

- name: "Execute a one shot backup of Squest"
hosts: localhost
gather_facts: true
Expand Down
4 changes: 2 additions & 2 deletions k8s/inventory/group_vars/all/squest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ squest_django:
TZ: "Europe/Paris"
DB_HOST: "mariadb"
DB_PORT: "3306"
REDIS_CACHE_HOST: "rfrm-redisfailover"
REDIS_CACHE_HOST: "redis"
DB_USER: "{{ squest_db.user }}"
DB_PASSWORD: "{{ squest_db.password }}"
WAIT_HOSTS: "mariadb:3306,rabbitmq:5672"
Expand All @@ -65,4 +65,4 @@ squest_django:
private_ssh_key: "{{ lookup('file', '/home/nico/Desktop/id_ed25519_squest_k8s_dev') + '\n' }}"
ssh_user: "squest_k8s_dev"
ssh_server: "siam017.gre.hpecorp.net"
remote_path: "/backup/squest_k8s_dev/backup"
remote_path: "/backup/squest_k8s_dev/"
13 changes: 12 additions & 1 deletion k8s/squest_k8s/tasks/02-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
apiVersion: v1
metadata:
name: "mariadb"
labels:
app: squest
service: mariadb
data:
root-password: "{{ squest_db.root_password |b64encode }}"
password: "{{ squest_db.password |b64encode }}"
Expand All @@ -43,6 +46,9 @@
kind: MariaDB
metadata:
name: mariadb
labels:
app: squest
service: mariadb
spec:
rootPasswordSecretKeyRef:
name: mariadb
Expand Down Expand Up @@ -100,6 +106,7 @@
namespace: "{{ squest_namespace }}"
labels:
app: squest
service: phpmyadmin
name: phpmyadmin-env
data: "{{ squest_phpmyadmin.env }}"

Expand All @@ -114,6 +121,7 @@
namespace: "{{ squest_namespace }}"
labels:
app: squest
service: phpmyadmin
name: phpmyadmin
spec:
replicas: 1
Expand Down Expand Up @@ -148,7 +156,7 @@
namespace: "{{ squest_namespace }}"
labels:
app: squest
app.kubernetes.io/name: squest-phpmyadmin
service: phpmyadmin
name: phpmyadmin-service
spec:
ports:
Expand All @@ -167,6 +175,9 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
labels:
app: squest
service: phpmyadmin
namespace: "{{ squest_namespace }}"
name: phpmyadmin-ingress
annotations: "{{ squest_phpmyadmin.ingress.annotation }}"
Expand Down
12 changes: 11 additions & 1 deletion k8s/squest_k8s/tasks/03-rabbitmq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
kind: Secret
metadata:
name: rabbitmq-user-secret
labels:
app: squest
service: rabbitmq
type: Opaque
stringData:
username: "{{ squest_rabbitmq.user }}"
Expand All @@ -63,6 +66,9 @@
kind: User
metadata:
name: rabbitmq-user
labels:
app: squest
service: rabbitmq
spec:
tags:
- administrator
Expand All @@ -81,7 +87,8 @@
kind: RabbitmqCluster
metadata:
labels:
app: rabbitmq
app: squest
service: rabbitmq
name: rabbitmq
spec:
replicas: 3
Expand Down Expand Up @@ -123,6 +130,9 @@
kind: Vhost
metadata:
name: squest-vhost
labels:
app: squest
service: rabbitmq
spec:
name: squest # vhost name
defaultQueueType: quorum # default queue type for this vhost; require RabbitMQ version 3.11.12 or above
Expand Down
7 changes: 5 additions & 2 deletions k8s/squest_k8s/tasks/04-redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,19 @@
type: Available
status: "True"

- name: Deploy Redis stack via CRD
- name: Deploy Redis
kubernetes.core.k8s:
kubeconfig: "{{ k8s_kubeconfig_path }}"
state: present
definition:
apiVersion: databases.spotahome.com/v1
kind: RedisFailover
metadata:
name: redisfailover
name: redis
namespace: "{{ squest_namespace }}"
labels:
app: squest
service: redis
spec:
sentinel:
replicas: 3
Expand Down
18 changes: 14 additions & 4 deletions k8s/squest_k8s/tasks/05-django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
apiVersion: v1
metadata:
name: squest-sa
labels:
app: squest
service: django
automountServiceAccountToken: true

- name: Create a role allowed to get info on jobs
Expand All @@ -20,6 +23,9 @@
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: role-get-jobs
labels:
app: squest
service: django
rules:
- verbs:
- list
Expand All @@ -39,7 +45,10 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: my-app
name: django-role-binding
labels:
app: squest
service: django
subjects:
- kind: ServiceAccount
name: squest-sa
Expand Down Expand Up @@ -77,8 +86,8 @@
kind: PersistentVolumeClaim
metadata:
labels:
service: django
app: squest
service: django
name: "{{ item }}"
spec:
accessModes:
Expand All @@ -105,8 +114,6 @@
backoffLimit: 3
spec:
securityContext:
# runAsUser: 1000
# runAsGroup: 1000
fsGroup: 999
containers:
- name: django
Expand Down Expand Up @@ -302,6 +309,9 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
labels:
app: squest
service: django
name: squest-ingress
annotations: "{{ squest_django.ingress.annotations }}"
spec:
Expand Down
3 changes: 1 addition & 2 deletions k8s/squest_k8s/tasks/07-maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace: "{{ squest_namespace }}"
labels:
app: squest
service: nginx
service: maintenance
name: nginx-config-maintenance
data:
nginx.conf: "{{ lookup('file', playbook_dir + '/../docker/maintenance.nginx.conf') }}"
Expand Down Expand Up @@ -48,7 +48,6 @@
containers:
- name: nginx
image: nginx:1.23.4-alpine
# command: ["nginx", "-c", "/etc/nginx/squest/nginx.conf"]
ports:
- containerPort: 8080
volumeMounts:
Expand Down
9 changes: 9 additions & 0 deletions k8s/squest_k8s/tasks/08-backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
kind: CronJob
metadata:
name: squest-backup
labels:
app: squest
service: backup
spec:
schedule: "{{ squest_django.backup.crontab }}"
jobTemplate:
Expand Down Expand Up @@ -61,6 +64,9 @@
kind: Secret
metadata:
name: squest-rsync-ssh-key
labels:
app: squest
service: backup
type: Opaque
data:
ssh.key: "{{ squest_django.externalize_backup_via_rsync.private_ssh_key |b64encode }}"
Expand All @@ -75,6 +81,9 @@
kind: CronJob
metadata:
name: squest-rsync-backup
labels:
app: squest
service: backup
spec:
schedule: "{{ squest_django.externalize_backup_via_rsync.crontab }}"
jobTemplate:
Expand Down

0 comments on commit b93724b

Please sign in to comment.