mabumusa1/kub8-api

Create Install

Closed this issue · 1 comments

To create a new Install we need to call 4 times,

  1. Create StatefulSet
  2. Create Service
  3. Create Certificate
  4. Create Ingress

Example: https://github.com/kubernetes-client/javascript/blob/ea5041dda50f1fd772fd66c058421fca98853f64/examples/ingress.js#L8

in below example for a client called: tadamon

all variables contains tadamon should be passed as a parameter

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: tadamon
spec:
  selector:
    matchLabels:
      app: tadamon-mautic # has to match .spec.template.metadata.labels
  serviceName: "tadamon-service"
  replicas: 1 # by default is 1
  template:
    metadata:
      labels:
        app: tadamon-mautic # has to match .spec.selector.matchLabels
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: tadamon-container
        image: 407780391754.dkr.ecr.ap-south-1.amazonaws.com/mautic_sc:latest
        env:
        - name: MAUTIC_DB_USER
          value: "tadamon_user"
        - name: MAUTIC_DB_PASSWORD
          value: "123456789"
        - name: MAUTIC_DB_NAME
          value: "tadamon"
        - name: MAUTIC_DB_HOST
          value: "db.internal"
        - name: client-name
          value: "tadamon"        
        ports:
        - containerPort: 80
          name: tadamon
        volumeMounts:
        - name: tadamon-claim
          mountPath: /code      
        tty: true
        workingDir: /code
      restartPolicy: Always          
  volumeClaimTemplates:
  - metadata:
      name: tadamon-claim
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "gp2"
      resources:
        requests:
          storage: 10Gi  
apiVersion: v1
kind: Service
metadata:
  name: tadamon-service
  namespace: default
  labels:
    app: tadamon-mautic
spec:
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  selector:
    app: tadamon-mautic
  type: ClusterIP
  sessionAffinity: None
  ipFamilies:
    - IPv4
  ipFamilyPolicy: SingleStack
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
  name: tadamon-secret
  namespace: default
spec:
  dnsNames:
    - tadamon.steercampaign.com
  issuerRef:
    group: cert-manager.io
    kind: ClusterIssuer
    name: letsencrypt-prod-ingress
  secretName: tadamon-secret
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: tadamon-ingress
  namespace: default
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod-ingress
status:
  loadBalancer:
    ingress:
      - hostname: >-
          a91db86aaa6a947ae8cf9a0ee09c740a-1073567115.ap-south-1.elb.amazonaws.com
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - tadamon.steercampaign.com
      secretName: tadamon-secret
  rules:
    - host: tadamon.steercampaign.com
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: tadamon-service
                port:
                  number: 80

Thanks @mlahlouh, merged