Skip to content
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

Kubernetes installation #12

Closed
oulfr opened this issue Oct 25, 2023 · 1 comment
Closed

Kubernetes installation #12

oulfr opened this issue Oct 25, 2023 · 1 comment

Comments

@oulfr
Copy link

oulfr commented Oct 25, 2023

Hello,

Is there any documentation on installing Aimeos in Kubernetes or Cloud?

@aimeos
Copy link
Owner

aimeos commented Oct 26, 2023

Installation in the cloud (e.g. AWS) is pretty straight forward if you have a git repository containing your application. You only need to check in the ./vendor/ directory too because otherwise there will be problems with credentials if you use private packages.

Kubernetes requires some experience. If you have a working Kubernetes environment, you can use this configuration for own setups as example:

---
---
apiVersion: v1
kind: Namespace
metadata:
  name: example-dev
---
# Database storage
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: example-dev-db
  namespace: example-dev
spec:
  storageClassName: local-path
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
---
apiVersion: v1
kind: Service
metadata:
  name: example
  namespace: example-dev
spec:
  selector:
    app: example
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: example-db
  namespace: example-dev
spec:
  selector:
    app: example-db
  ports:
    - protocol: TCP
      port: 3306
      targetPort: 3306
---
# Database
apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-db
  namespace: example-dev
  labels:
    app: example-db
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: example-db
  template:
    metadata:
      name: example-db
      namespace: example-dev
      labels:
        app: example-db
    spec:
      volumes:
        - name: example-db
          persistentVolumeClaim:
            claimName: example-dev-db
      containers:
        - name: mariadb
          image: mariadb
          volumeMounts:
            - mountPath: "/var/lib/mysql"
              name: example-db
          ports:
            - containerPort: 3306
          env:
            - name: MARIADB_ROOT_PASSWORD
              value: "example"
            - name: MARIADB_DATABASE
              value: "example"
            - name: MARIADB_USER
              value: "example"
            - name: MARIADB_PASSWORD
              value: "example"
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: example-setup
  namespace: example-dev
data:
  99-setup.sh: |
    git clone https://github.com/aimeos/example /aimeos
    chgrp -R application /aimeos/bootstrap /aimeos/storage
    chmod -R g+w /aimeos/bootstrap /aimeos/storage
    rm -rf /app && mv /aimeos /app
    php /app/artisan optimize
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: example
  labels:
    app: example
  namespace: example-dev
spec:
  replicas: 1
  revisionHistoryLimit: 0
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 50%
      maxSurge: 1
  selector:
    matchLabels:
      app: example
  template:
    metadata:
      labels:
        app: example
    spec:
      volumes:
      - name: setup
        configMap:
          name: example-setup
      containers:
      - name: nginx-php
        image: webdevops/php-nginx:8.2-alpine
        ports:
          - containerPort: 80
        volumeMounts:
        - name: setup
          mountPath: /opt/docker/provision/entrypoint.d/99-setup.sh
          subPath: 99-setup.sh
        env:
        - name: WEB_DOCUMENT_ROOT
          value: /app/public/
        - name: PHP_DISMOD
          value: "ioncube"
        - name: PHP_MEMORY_LIMIT
          value: "128M"
        - name: PHP_MAX_EXECUTION_TIME
          value: "30"
        - name: DB_CONNECTION
          value: "mysql"
        - name: DB_HOST
          value: "example-db"
        - name: DB_PORT
          value: "3306"
        - name: DB_DATABASE
          value: "example"
        - name: DB_USERNAME
          value: "example"
        - name: DB_PASSWORD
          value: "example"
        - name: APP_NAME
          value: "example"
        - name: APP_KEY
          value: "base64:mAoDuaiV/lT/EwXXOC7Ohy7Qs8yiivioJuBU4rrTG8s="
        - name: APP_URL
          value: "https://dev.example.com"
        - name: ASSET_URL
          value: "https://dev.example.com"
        - name: APP_DEBUG
          value: "1"
        - name: APP_ENV
          value: "local"
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: example-issuer
  namespace: example-dev
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    privateKeySecretRef:
      name: example-issuer-key
    solvers:
    - http01:
        ingress:
          ingressClassName: traefik
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: dev-example-de
  namespace: example-dev
spec:
  secretName: example-secret
  privateKey:
    rotationPolicy: Always
  dnsNames:
  - dev.example.com
  issuerRef:
    name: example-issuer
    kind: Issuer
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: example-ingress-http
  namespace: example-dev
spec:
  entryPoints:
  - web
  routes:
  - match: Host(`dev.example.com`)
    kind: Rule
    services:
    - name: example
      port: 80
      passHostHeader: true
      sticky:
        cookie:
          httpOnly: true
          name: example-host
          sameSite: lax
      strategy: RoundRobin
      weight: 10
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: example-ingress-https
  namespace: example-dev
spec:
  entryPoints:
  - websecure
  routes:
  - match: Host(`dev.example.com`)
    kind: Rule
    services:
    - name: example
      port: 80
      passHostHeader: true
      sticky:
        cookie:
          httpOnly: true
          name: example-host
          sameSite: lax
      strategy: RoundRobin
      weight: 10
  tls:
    secretName: example-secret

@oulfr oulfr closed this as completed Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants