Skip to content
Snippets Groups Projects
app.yml 7.51 KiB
Newer Older
Pierre Ozoux's avatar
Pierre Ozoux committed
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/component: app
    app.kubernetes.io/instance: ${FQDN}
    app.kubernetes.io/name: nextcloud
    app.kubernetes.io/part-of: Nextcloud
  name: ${FQDN}-app
  namespace: ${NS}
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: http
  selector:
Hugo Renard's avatar
Hugo Renard committed
    app.kubernetes.io/component: app
Pierre Ozoux's avatar
Pierre Ozoux committed
    app.kubernetes.io/instance: ${FQDN}
    app.kubernetes.io/name: nextcloud
    app.kubernetes.io/part-of: Nextcloud
  type: ClusterIP
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/tls-acme: "true"
    nginx.ingress.kubernetes.io/proxy-body-size: 100g
    nginx.ingress.kubernetes.io/proxy-request-buffering: "off"
  labels:
    app.kubernetes.io/component: web
    app.kubernetes.io/instance: ${FQDN}
    app.kubernetes.io/name: nextcloud
    app.kubernetes.io/part-of: Nextcloud
  name: ${FQDN}-web
  namespace: ${NS}
spec:
  rules:
  - host: ${FQDN_DOTS}
    http:
      paths:
      - backend:
Hugo Renard's avatar
Hugo Renard committed
          serviceName: ${FQDN}-app
Pierre Ozoux's avatar
Pierre Ozoux committed
          servicePort: http
        path: /
  tls:
  - hosts:
    - ${FQDN_DOTS}
    secretName: ${FQDN}-tls
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/component: app
    app.kubernetes.io/instance: ${FQDN}
    app.kubernetes.io/name: nextcloud
    app.kubernetes.io/part-of: Nextcloud
  name: ${FQDN}-app
  namespace: ${NS}
spec:
  progressDeadlineSeconds: 600
  replicas: ${REPLICAS}
Pierre Ozoux's avatar
Pierre Ozoux committed
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/component: app
      app.kubernetes.io/instance: ${FQDN}
      app.kubernetes.io/name: nextcloud
      app.kubernetes.io/part-of: Nextcloud
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
Pierre Ozoux's avatar
Pierre Ozoux committed
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/component: app
        app.kubernetes.io/instance: ${FQDN}
        app.kubernetes.io/name: nextcloud
        app.kubernetes.io/part-of: Nextcloud
    spec:
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 20
            preference:
              matchExpressions:
              - key: stateless
                operator: In
                values:
                - "true"
Pierre Ozoux's avatar
Pierre Ozoux committed
      containers:
Hugo Renard's avatar
Hugo Renard committed
      - image: libresh/nextcloud:${NC_WEB_IMAGE_TAG}
        imagePullPolicy: Always
        name: web
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        env:
        - name: BACKEND_HOST
          value: localhost
        livenessProbe:
          httpGet:
            path: /heartbeat
            port: 80
            httpHeaders:
            - name: Host
              value: localhost
        readinessProbe:
          httpGet:
            path: /heartbeat
            port: 80
            httpHeaders:
            - name: Host
              value: localhost
        resources: 
          requests:
            memory: "80Mi"
          limits:
            memory: "400Mi"
Pierre Ozoux's avatar
Pierre Ozoux committed
      - command: ["/bin/sh"]
        args:
        - -c
        - >-
          /runtime/patches/apply.sh &&
          php-fpm
Pierre Ozoux's avatar
Pierre Ozoux committed
        env:
#cat ./version.php | grep 'array(' | cut -d\( -f2 | cut -d\) -f1 | sed 's/,/\./g'
        - name: VERSION
          value: ${NC_VERSION}
        - name: INSTALLED
          value: "true"
        - name: OBJECTSTORE_S3_KEY 
          valueFrom:
            secretKeyRef:
              key: AWS_ACCESS_KEY_ID 
              name: ${FQDN}-s3
        - name: OBJECTSTORE_S3_SECRET 
          valueFrom:
            secretKeyRef:
              key: AWS_SECRET_ACCESS_KEY
              name: ${FQDN}-s3
        - name: MAIL_FROM_ADDRESS 
          valueFrom:
            secretKeyRef:
              key: mail_from_address
              name: ${NS}-smtp
        - name: SMTP_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password 
              name: ${NS}-smtp
        - name: SMTP_NAME 
          valueFrom:
            secretKeyRef:
              key: username
              name: ${NS}-smtp
        - name: DB_PASSWORD 
          valueFrom:
            secretKeyRef:
              key: password 
              name: nextcloud.pg-${PG_DOMAIN}.credentials
        envFrom:
        - secretRef:
            name: ${FQDN}-app
        image: libresh/nextcloud:${NC_IMAGE_TAG}
        imagePullPolicy: Always
        name: app
Hugo Renard's avatar
Hugo Renard committed
        securityContext:
          runAsUser: 82
          runAsGroup: 82
Hugo Renard's avatar
Hugo Renard committed
          httpGet:
            path: /heartbeat
            port: 80
            httpHeaders:
            - name: Host
              value: localhost
        readinessProbe:
          exec:
            command:
            - /php-fpm-healthcheck
Pierre Ozoux's avatar
Pierre Ozoux committed
        ports:
        - containerPort: 9000
          name: api
          protocol: TCP
        resources: 
          requests:
            memory: "80Mi"
          limits:
Hugo Renard's avatar
Hugo Renard committed
            memory: "400Mi"
Pierre Ozoux's avatar
Pierre Ozoux committed
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      terminationGracePeriodSeconds: 30
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  labels:
    app.kubernetes.io/component: cron 
    app.kubernetes.io/instance: ${FQDN}-cron
    app.kubernetes.io/part-of: nextcloud
  name: ${FQDN}-cron
spec:
  jobTemplate:
    metadata:
      labels:
        app.kubernetes.io/component: cron
        app.kubernetes.io/instance: ${FQDN}-cron
        app.kubernetes.io/part-of: nextcloud
      name: nextcloud-cron
    spec:
      manualSelector: false
      template:
        metadata:
          labels:
            app.kubernetes.io/component: cron
            app.kubernetes.io/instance: ${FQDN}-cron
            app.kubernetes.io/part-of: nextcloud
          name: nextcloud-cron
        spec:
          containers:
          - args:
              - /bin/echo start cron;/usr/local/bin/php occ status;/usr/local/bin/php /usr/src/nextcloud/cron.php;/bin/echo stop cron;/usr/local/bin/php occ config:list | grep lastcron | cut -d\" -f4 | xargs -I{} date -d @{}
            command:
            - /bin/sh
            - -c
            env:
            - name: INSTALLED
              value: "true"
            - name: VERSION
              value: ${NC_VERSION}
            - name: OBJECTSTORE_S3_KEY 
              valueFrom:
                secretKeyRef:
                  key: AWS_ACCESS_KEY_ID 
                  name: ${FQDN}-s3
            - name: OBJECTSTORE_S3_SECRET 
              valueFrom:
                secretKeyRef:
                  key: AWS_SECRET_ACCESS_KEY
                  name: ${FQDN}-s3
            - name: MAIL_FROM_ADDRESS 
              valueFrom:
                secretKeyRef:
                  key: mail_from_address
                  name: ${NS}-smtp
            - name: SMTP_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: password 
                  name: ${NS}-smtp
            - name: SMTP_NAME 
              valueFrom:
                secretKeyRef:
                  key: username
                  name: ${NS}-smtp
            - name: DB_PASSWORD 
              valueFrom:
                secretKeyRef:
                  key: password 
                  name: nextcloud.pg-${PG_DOMAIN}.credentials
            envFrom:
            - secretRef:
                name: ${FQDN}-app
            image: libresh/nextcloud:${NC_IMAGE_TAG}
            imagePullPolicy: Always
            name: cli
          restartPolicy: OnFailure
  schedule: '*/5 * * * *'
  successfulJobsHistoryLimit: 3
  suspend: false