Creating the Server Container

Use the following steps to create the server container.

Procedure

  1. Ensure that the kubectl context is set to the correct environment.
    The mechanism differs based on the Kubernetes environment in use.
  2. Create a key that is used by the server and add the new key to the ConfigMap that contains the configuration for the container.
    For example,
    openssl req -nodes -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365; cat key.pem cert.pem > server.pem
  3. Create a ConfigMap definition file that is named server-config.yaml.
    This definition file contains the configuration YAML for the server container. For example,
    apiVersion: v1 
    kind: ConfigMap 
    metadata: 
      name: server-config 
      namespace: default 
    data: 
      server.pem: |
        <insert-server.pem-here>
    
      config.yaml: |
        general: 
          ports:
            ldap:  0
            ldaps: 9636
    
          id: test-server
    
          license:
            key: "add-your-license-key-here"
            accept: standard
    
          admin: 
            pwd: passw0rd1
    
          ssl:
            cert-label: 'server-key'
    
          audit:
            enabled: true
      
        server:
          suffixes:
          - dn: dc=ibm.com
            object-classes:
            - domain
    
          change-log:
            enabled: true
            max-days: 56
            max-entries: 99999
            max-hours: 12
    
        keyfile:
          keys:
          - label: 'server-key'
            key: "@/var/isvd/config/server.pem"
  4. Create the ConfigMap.
    kubectl create –f server-config.yaml
  5. Create the persistent volume claim that is used by the seed container to store the Directory server data. The mechanism varies based on the Kubernetes environment in use. The following example shows how to create a persistent volume claim in an IBM cloud environment.
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: isvd-claim
      labels:
        billingType: "hourly"
        region: au-syd
        zone: syd04
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 45Gi
      storageClassName: ibmc-block-silver
  6. Create a deployment file that is named server-container.yaml.
    This deployment file defines a server container for your environment.
    # 
    # The deployment description of the Verify Directory server container.
    #
    
    apiVersion: apps/v1
    kind: Deployment
    
    metadata:
      name: isvd-server
      labels:
        app: isvd-server
    
    spec:
      selector:
        matchLabels:
          app: isvd-server
    
      template: 
        metadata:
          labels:
            app: isvd-server
    
        spec:
          # The name of the service account which has the required
          # capabilities enabled for the isvd container.
          serviceAccountName: isvd
    
          # We use a volume to store the configuration for the 
          # environment.
          volumes:
          - name: config-volume
            configMap:
              name: server-config
          - name: data-volume 
            persistentVolumeClaim: 
              claimName: isvd-claim
    
          containers:
          - name: isvd-server
    
            # The fully qualified name of the image.
            image: icr.io/isvd/verify-directory-server:latest
    
            # The port on which the container will be listening.
            ports:
            - containerPort: 9636
    
            # Environment definition.
            env:
            - name: YAML_CONFIG_FILE
              value: /var/isvd/config/config.yaml  
              
            # The configuration volume.
            volumeMounts:
            - name: config-volume
              mountPath: /var/isvd/config
            - name: data-volume
              mountPath: /var/isvd/data
    
            # The liveness, readiness and startup probes are used by
            # Kubernetes to monitor the health of the container.  Our 
            # health is governed by the health_check.sh script which is
            # provided by the container.
            livenessProbe:
              exec:
                command:
                - /sbin/health_check.sh 
                - livenessProbe
              initialDelaySeconds: 5
              periodSeconds: 10
    
            readinessProbe:
              exec:
                command:
                - /sbin/health_check.sh
              initialDelaySeconds: 5
              periodSeconds: 10 
    
            livenessProbe:
              exec:
                command:
                - /sbin/health_check.sh 
                - startupProbe
              initialDelaySeconds: 5
              periodSeconds: 10
  7. Create the container.
    kubectl create –f server-container.yaml
  8. You can monitor the bootstrapping of the container that uses the logs command.
    kubectl logs -f `kubectl get -o json pods -l app=isvd-server | jq -r .items[0].metadata.name`
  9. Create a configuration file that is named server-service.yaml.
    This configuration file defines a service that can be used to access the server. The type of service that is defined differs based on whether the 'load balancer' service type is supported in the environment.
    • If the 'load balancer' service type is not supported in your environment, Tythe following definition can be used.

      # 
      # The service description of the Verify Directory server
      # service.  This is the entry point into the environment and can be
      # accessed over port 30636 from outside of the Kubernetes cluster.
      #
      
      apiVersion: v1
      kind: Service
      
      metadata:
        name: isvd-server
      
      spec:
        ports:
        - port: 9636
          name: isvd-server
          protocol: TCP
          nodePort: 30636
      
        selector:
          app: isvd-server
      
        type: NodePort
    • If the 'load balancer' service type is supported in your environment, the following definition can be used.
      
      # LoadBalancer service definition....
      apiVersion: v1
      kind: Service
      metadata:
        name: isvd-server
      spec:
        type: LoadBalancer
        ports:
        - port: 636
        - targetPort: 9636
        selector:
          app: isvd-server
  10. Create the service.
    kubectl create –f server-service.yaml
  11. Determine the IP address.
    • If a LoadBalancer service was defined, determine the external IP address of the service, and then use the ldapsearch command to access the server (port 636).
       kubectl get service isvd-server --watch
    • If a NodePort service was defined, determine the IP address of the Kubernetes cluster, and then use your ldapsearch command to access the server (port 30636).
    In a minikube environment, the IP address of the cluster can be obtained with the following command.
    minikube ip
    In an IBM cloud environment, the IP address of the cluster can be obtained with the following command.
    ibmcloud cs workers -c <cluster-name> --json | jq -r .[0].publicIP