Kubernetes deployment database connection error

8/1/2018

I'm trying to deploy GLPI application (http://glpi-project.org/) over my Kubernetes cluster but i encounter an issue.

Here is my deployment code:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pv-claim-glpi
  labels:
    type: openebs
spec:
  storageClassName: openebs-storageclass
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: glpi
  namespace: jb
  labels:
    app: glpi
spec:
  selector:
    matchLabels:
      app: glpi
  replicas: 1 # tells deployment to run 1 pods matching the template
  template: # create pods using pod definition in this template
    metadata:
      # unlike pod-nginx.yaml, the name is not included in the meta data as a unique name is
      # generated from the deployment name
      labels:
        app: glpi
    spec:
      volumes:
      - name: pv-storage-glpi
        persistentVolumeClaim:
          claimName: pv-claim-glpi
      containers:
      - name: mariadb
        image: mariadb
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "glpi"
        - name: MYSQL_DATABASE
          value: "glpi"
        - name: MYSQL_USER
          value: "glpi"
        - name: MYSQL_PASSWORD
          value: "glpi"
        - name: GLPI_SOURCE_URL
          value: "https://forge.glpi-project.org/attachments/download/2020/glpi-0.85.4.tar.gz"
        ports:
        - containerPort: 3306
          name: mariadb
        volumeMounts:
        - mountPath: /var/lib/mariadb/
          name: pv-storage-glpi
          subPath: mariadb
      - name: glpi
        image: driket54/glpi
        ports:
        - containerPort: 80
          name: http
        - containerPort: 8090
          name: https
        volumeMounts:
        - mountPath: /var/glpidata
          name: pv-storage-glpi
          subPath: glpidata
---
apiVersion: v1
kind: Service
metadata:
  name: glpi
  namespace: jb
spec:
  selector:
    app: glpi
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: http
    name: http
  - protocol: "TCP"
    port: 8090
    targetPort: https
    name: https
  - protocol: "TCP"
    port: 3306
    targetPort: mariadb
    name: mariadb
  type: NodePort  
---  

The docker image is properly deployed but in my test phase, during the setup of the app, i get the following error while setting up the database (mysql).

error glpi

I've already checked the credentials (host, username, password) and the are correct

Please help

--
cloud
docker
dockerfile
kubernetes
kubernetes-pod

1 Answer

8/23/2018

Not really an answer since I don' t have the Kubernetes knowledge expected, but I can't add a comment yet :(

What you should alter first is your GLPi version. Use this link. It's the last one: https://github.com/glpi-project/glpi/releases/download/9.3.0/glpi-9.3.tgz

Then you may use cli tools to setup the database. https://glpi-install.readthedocs.io/en/latest/command-line.html

Using what I get from your file:

php scripts/cliinstall.php --host=mariadb(not sure about this one in your environment but you get hte idea) --db=glpi --user=glpi --pass=glpi
-- Óscar Beiro
Source: StackOverflow