This topic describes how to install Application Live View Custom Resource Definitions. The Application Live View CRD Controller interacts with Application Live View Server to manage the application instance objects. It fetches the list of application instances from Application Live View Server. These instances are registered as custom resources with the Kubernetes API server. Each resource displays various metrics like framework, version, cpu, memory etc.

Deploy Service Account for Application Live View CRD

For the Application Live View CRD Controller to register the custom resources with the Kubernetes API server, a service account should be created with a get, list, create, update, patch and delete roles bound to service account using cluster role binding.

  1. Create a service account yaml (app-live-view-crd-service-account.yaml) as shown below:

    app-live-view-crd-service-account.yaml

    apiVersion: v1
        kind: ServiceAccount
        metadata:
          name: app-live-view-crd-service-account
        ---
        apiVersion: rbac.authorization.k8s.io/v1
        kind: ClusterRole
        metadata:
          name: app-live-view-crd-cluster-role
        rules:
          - apiGroups: ["appliveview.tanzu.vmware.com"]
            resources: ["appliveview-instances"]
            verbs: ["get", "list", "create", "update", "patch", "delete"]
        ---
        apiVersion: rbac.authorization.k8s.io/v1
        kind: ClusterRoleBinding
        metadata:
          name: app-live-view-crd-cluster-role-binding
        roleRef:
          apiGroup: rbac.authorization.k8s.io
          kind: ClusterRole
          name: app-live-view-crd-cluster-role
        subjects:
          - kind: ServiceAccount
            name: app-live-view-crd-service-account
    
  2. Deploy the Service account using kubectl CLI. Run:

    kubectl apply -f app-live-view-crd-service-account.yaml
    


Deploy CRD Template

The below CRD template defines the structure of the resource that is exposed on the Kubernetes API server:

  1. Create a custom resource definition yaml (app-live-view-crd-template.yaml) as shown below:

    app-live-view-crd-template.yaml

        apiVersion: apiextensions.k8s.io/v1
        kind: CustomResourceDefinition
        metadata:
          name: appliveview-instances.tanzu.vmware.com
        spec:
          group: appliveview.tanzu.vmware.com
          scope: Namespaced
          names:
            # plural name to be used in the URL: /apis/<group>/<version>/<plural>
            plural: appliveview-instances
            # singular name to be used as an alias on the CLI and for display
            singular: appliveview-instance
            # kind is normally the CamelCased singular type. Your resource manifests use this.
            kind: Instance
            # shortNames allow shorter string to match your resource on the CLI
            shortNames:
            - appliveview
          versions:
            - name: v1alpha1
              served: true
              storage: true
              schema:
                openAPIV3Schema:
                  type: object
                  properties:
                    spec:
                      type: object
                      properties:
                        appName:
                          type: string
                        url:
                          type: string
                        health:
                          type: string
                        frameWork:
                          type: string
                        version:
                          type: string
                        buildVersion:
                          type: string
                        actuatorHealthUrl:
                          type: string
                        actuatorPath:
                          type: string
                        applicationUrl:
                          type: string
                        appLiveViewBackendUrl:
                          type: string
                        memory:
                          type: string
                        liveThreads:
                          type: string
                        cpuUsage:
                          type: string
                        hints:
                          type: string
                        podId:
                          type: string
                    status:
                      type: object
                      properties:
              additionalPrinterColumns:
              - name: applicationName
                type: string
                description: The name of the application
                jsonPath: .spec.appName
              - name: url
                type: string
                description: The url of the instance
                jsonPath: .spec.url
              - name: health
                type: string
                description: The status of the instance
                jsonPath: .spec.health
              - name: frameWork
                type: string
                description: The frameWork of the instance
                jsonPath: .spec.frameWork
              - name: version
                type: string
                description: The boot version of the instance
                jsonPath: .spec.version
              - name: buildVersion
                type: string
                description: The build version of the instance
                jsonPath: .spec.buildVersion
              - name: actuatorPath
                type: string
                description: The actuator path of the instance
                jsonPath: .spec.actuatorPath
                priority: 1
              - name: actuatorHealthUrl
                type: string
                description: The actuator health url of the instance
                jsonPath: .spec.actuatorHealthUrl
                priority: 1
              - name: applicationUrl
                type: string
                description: The application url of the instance
                jsonPath: .spec.applicationUrl
                priority: 1
              - name: appLiveViewBackendUrl
                type: string
                description: Application Live View backend URL
                jsonPath: .spec.appLiveViewBackendUrl
                priority: 1
              - name: memory
                type: string
                description: Application Live View instance memory
                jsonPath: .spec.memory
                priority: 1
              - name: liveThreads
                type: string
                description: Application Live View instance liveThreads
                jsonPath: .spec.liveThreads
                priority: 1
              - name: cpuUsage
                type: string
                description: Application Live View instance cpuUsage
                jsonPath: .spec.cpuUsage
                priority: 1
              - name: hints
                type: string
                description: Application Live View instance hints
                jsonPath: .spec.hints
                priority: 1
              - name: podId
                type: string
                description: Application Live View instance podId
                jsonPath: .spec.podId
                priority: 1
    
  2. Deploy the custom resource definition template using kubectl CLI. Run:

    kubectl apply -f app-live-view-crd-template.yaml
    


Deploy Application Live View CRD Controller

To deploy Application Live View CRD Controller, follow the below steps:

  1. Create a deployment yaml (crd-controller.yaml) as shown below and replace the placeholder values as necessary:

    crd-controller.yaml

        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: app-live-view-crd-controller
          labels:
            app: app-live-view-crd-controller
        spec:
          replicas: 1
          selector:
            matchLabels:
              app: app-live-view-crd-controller
          template:
            metadata:
              labels:
                app: app-live-view-crd-controller
            spec:
              serviceAccount: app-live-view-crd-service-account
              containers:
              - name: crd-controller
                image: registry.pivotal.io/app-live-view/application-live-view-k8s-custom-resources:0.1.0
                imagePullPolicy: Always
                ports:
                - containerPort: 8088
                env:
                  # this url makes the controller pod communicate with the Application Live View Service Name and can be modified as you wish
                - name: app.live.view.crd.appLiveViewServerEndpoint
                  value: "{{ TO BE CHANGED }}"  # Mandatory. If you want to access backend URL from CRD internally within the cluster and same namespace, you specify the service name URL like http://application-live-view-5112:5112
    
                #- name: app.live.view.crd.appLiveViewServerExternalEndpoint
                  #value: "{{ TO BE CHANGED }}"  # This is optional. If you want to access backend URL from CRD externally, then you specify the load balancer URL here like http://${EXTERNAL_HOST_NAME}:5112. 
    
                  # this namespace env variable retrieves the namespace from metadata
                - name: app.live.view.crd.name-space
                  valueFrom:
                    fieldRef:
                      fieldPath: metadata.namespace
    
  2. Deploy the crd controller using kubectl CLI. Run:

    kubectl apply -f crd-controller.yaml
    
  3. Verify the deployment by running the below command:

    kubectl get pods
    

    crd-controller pod should be in running state


Verify CRD Controller

Run the below command to fetch the list of application instances registered with Application Live View Server

kubectl get appliveview-instances
check-circle-line exclamation-circle-line close-line
Scroll to top icon