-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration du cluster kubernetes #1064
Draft
niladic
wants to merge
8
commits into
master
Choose a base branch
from
task/kubernetes-config
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
71bb50c
Add kubernetes config
niladic ae8dbb4
Fix incorrect env var
niladic f4f0578
Document beta api usage
niladic ea3d62d
Fix cronjob
niladic 31d7a2d
Add ingress, preprod and metabase
niladic ab79613
Merge branch 'master' into task/kubernetes-config
niladic d861fe8
Update metabase
niladic b692125
Supprime Azure
niladic File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: aplus-app | ||
labels: | ||
app: aplus | ||
spec: | ||
type: NodePort | ||
ports: | ||
- port: 80 | ||
targetPort: 9000 | ||
selector: # Should be a Pod selector | ||
app: aplus | ||
tier: frontend | ||
externalIPs: | ||
- 54.38.254.141 | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: aplus-files-pvc | ||
labels: | ||
app: aplus | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 5Gi | ||
storageClassName: csi-cinder-classic | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: aplus-app-deployment | ||
labels: | ||
app: aplus | ||
spec: | ||
replicas: 1 | ||
selector: # Should match .spec.template | ||
matchLabels: | ||
app: aplus | ||
tier: frontend | ||
strategy: | ||
type: Recreate # here RollingUpdate is not well handled by app sql queries | ||
template: | ||
metadata: | ||
labels: | ||
app: aplus | ||
tier: frontend | ||
spec: | ||
containers: | ||
- image: administrationplus.azurecr.io/aplus:master-20210526-084710z-f9c361b67edc2536f89e0cf1d1190a7467b6dba7 | ||
name: aplus-app | ||
env: | ||
- name: APP_HOST | ||
value: aplus.beta.gouv.fr | ||
- name: APP_HTTPS | ||
value: "false" | ||
- name: APPLICATION_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-application-secret | ||
key: APPLICATION_SECRET | ||
- name: DATABASE_URL | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-db-app-secret | ||
key: DATABASE_URL | ||
- name: EVOLUTIONS_AUTOAPPLY | ||
value: "true" | ||
- name: FEATURE_AUTO_ADD_EXPERT | ||
value: "true" | ||
- name: FEATURE_SEND_APPLICATIONS_ANYWHERE | ||
value: "true" | ||
- name: FEATURE_SMS_MANDAT | ||
value: "false" | ||
- name: FEATURE_WEEKLY_EMAILS | ||
value: "true" | ||
- name: FILES_EXPIRATION_IN_DAYS | ||
value: "15" | ||
- name: FILES_PATH | ||
value: "/app/files" | ||
- name: GROUPS_WHICH_CANNOT_HAVE_INSTRUCTORS | ||
value: "f32d20bf-a201-4875-9c69-16a5a4ad2f9c,ecb83438-b78b-4fbc-b0cd-880ce55562df" | ||
- name: MAIL_HOST | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-email-secret | ||
key: MAIL_HOST | ||
- name: MAIL_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-email-secret | ||
key: MAIL_PASSWORD | ||
- name: MAIL_PORT | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-email-secret | ||
key: MAIL_PORT | ||
- name: MAIL_USER | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-email-secret | ||
key: MAIL_USER | ||
- name: NOTIFICATION_EMAIL_BLACKLIST | ||
value: "daniel.balmy@beta.gouv.fr" | ||
- name: SMS_USE_LIVE_API | ||
value: "false" | ||
- name: WEEKLY_EMAILS_DAY_OF_WEEK | ||
value: tuesday | ||
- name: WEEKLY_EMAILS_HOUR_OF_DAY | ||
value: "10" | ||
- name: WEEKLY_EMAILS_MAX_NUMBER | ||
value: "1000" | ||
|
||
ports: | ||
- containerPort: 9000 | ||
volumeMounts: | ||
- name: aplus-files-pv | ||
mountPath: /app/files | ||
imagePullSecrets: | ||
- name: acr-docker-creds | ||
volumes: | ||
- name: aplus-files-pv | ||
persistentVolumeClaim: | ||
claimName: aplus-files-pvc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: aplus-db-backup-script | ||
data: | ||
backup-script: | | ||
set -e | ||
apt-get update | ||
apt-get install -y jq postgresql-client-11 | ||
pip install python-swiftclient==3.12.0 | ||
pip install python-keystoneclient==4.2.0 | ||
|
||
if [ ! -s /key/key.pub ] | ||
then | ||
echo "Stopping: no public key" | ||
exit 0 | ||
fi | ||
gpg --no-tty --import /key/key.pub | ||
|
||
# Create new backup | ||
NOW="$(date +"%Y-%m-%d-%s")" | ||
FILENAME="$DATABASE_BACKUP_PREFIX.$NOW.pgdump.gz" | ||
pg_dump -Fc $DATABASE_NAME | gzip > $FILENAME | ||
gpg --batch --trust-model always --output "${FILENAME}.gpg" --recipient ${RECIPIENT_PUBLIC_KEY_EMAIL} --encrypt ${FILENAME} | ||
swift --os-auth-token $AUTH_TOKEN --os-storage-url $STORAGE_URL upload $STORAGE_CONTAINER "${FILENAME}.gpg" | ||
|
||
# Cleanup old backups | ||
while read line | ||
do | ||
date=$(echo "$line" | jq -r '.last_modified') | ||
if [ $(date -d "$date" +%s) -le $(date +%s -d "$RETENTION_NUM_OF_DAYS days ago") ] | ||
then | ||
OLD=$(echo "$line" | jq -r '.name') | ||
echo WILL DELETE OLD BACKUP $OLD | ||
swift --os-auth-token $AUTH_TOKEN --os-storage-url $STORAGE_URL delete $STORAGE_CONTAINER "$OLD" | ||
fi | ||
done < <(swift --os-auth-token $AUTH_TOKEN --os-storage-url $STORAGE_URL list --json $STORAGE_CONTAINER | jq -c '.[]') | ||
--- | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: aplus-db-backup-job | ||
spec: | ||
schedule: "0 * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: aplus-db-backup | ||
image: python:3 | ||
env: | ||
- name: AUTH_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: ovh-storage-creds | ||
key: AUTH_TOKEN | ||
- name: DATABASE_BACKUP_PREFIX | ||
value: "aplus-db" | ||
- name: DATABASE_NAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-db-app-secret | ||
key: DATABASE_NAME | ||
- name: PGHOST | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-db-app-secret | ||
key: DATABASE_HOST | ||
- name: PGPASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-db-postgres-secret | ||
key: POSTGRES_PASSWORD | ||
- name: PGUSER | ||
value: postgres | ||
- name: RECIPIENT_PUBLIC_KEY_EMAIL | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-backup-pub-key | ||
key: RECIPIENT_PUBLIC_KEY_EMAIL | ||
- name: RETENTION_NUM_OF_DAYS | ||
value: "2" | ||
- name: STORAGE_CONTAINER | ||
value: "aplus-test-storage" | ||
- name: STORAGE_URL | ||
valueFrom: | ||
secretKeyRef: | ||
name: ovh-storage-creds | ||
key: STORAGE_URL | ||
volumeMounts: | ||
- name: script | ||
mountPath: "/script" | ||
- name: public-key | ||
mountPath: "/key" | ||
command: ["bash", "/script/backup.sh"] | ||
volumes: | ||
- name: script | ||
configMap: | ||
name: aplus-db-backup-script | ||
items: | ||
- key: backup-script | ||
path: "backup.sh" | ||
- name: public-key | ||
secret: | ||
secretName: aplus-backup-pub-key | ||
items: | ||
- key: RECIPIENT_PUBLIC_KEY | ||
path: "key.pub" | ||
restartPolicy: Never | ||
backoffLimit: 4 | ||
# ttlSecondsAfterFinished is not activated on the cluster |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: aplus-db | ||
labels: | ||
app: aplus | ||
spec: | ||
clusterIP: None | ||
ports: | ||
- port: 5432 | ||
selector: | ||
app: aplus | ||
tier: postgres | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: aplus-db-pvc | ||
labels: | ||
app: aplus | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 10Gi | ||
storageClassName: csi-cinder-classic | ||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: aplus-db-statefulset | ||
labels: | ||
app: aplus | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: aplus | ||
tier: postgres | ||
serviceName: aplus-db | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: aplus | ||
tier: postgres | ||
spec: | ||
containers: | ||
- name: postgres-database | ||
image: postgres:11 | ||
volumeMounts: | ||
- name: aplus-db-pv | ||
mountPath: /var/lib/postgresql/data | ||
env: | ||
- name: POSTGRES_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: aplus-db-postgres-secret | ||
key: DATABASE_URL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. je vois POSTGRES_PASSWORD et DATABASE_URL c'est normal ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bien vu ! |
||
- name: PGDATA | ||
value: /var/lib/postgresql/data/pgdata | ||
volumes: | ||
- name: aplus-db-pv | ||
persistentVolumeClaim: | ||
claimName: aplus-db-pvc |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c'est normal le v1beta1 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oui, la feature est stable à partir de kubernetes v1.21 https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ et on est sur v1.20 => Je vais ajouter un commentaire