Helm CR Integration

Overview

The Service Proxy for Kubernetes Custom Resources, SPK CRs, are collections of application traffic management objects, used to configure the Service Proxy Traffic Management Microkernel (TMM) through the Kubernetes API. You can install SPK CRs after deploying a clustered application, or deploy them with the application using Helm, the recommended method.

This document demonstrates how to install an Nginx web application, the required Kubernetes Service object, and the F5SPKIngress TCP CR using Helm.

Templates

Helm templates are key for supporting complex Kubernetes deployments, and are implemented using the Go programming language. Template directives, written as a set of curly brackets, receive values from the Helm command line interface (CLI). For example, the {{ .Values.app.object.name }} template directive receives the value passed using the --set app.object.name=<value> command. Helm then creates a release, sending the template data to the Kubernetes API. Helm charts often contain many templates, with many directives. The important point to remember; templates enable complicated applications to be installed, deleted, modified, or upgraded with a single command.

Values

As mentioned, Helm parameter values provide configuration data to template directives. There are two ways to pass values to templates using the Helm CLI; the --set option, or a YAML values file referenced using the -f option.

_images/spk_info.png Note: Helm values that modify default template values are also referred to as override values, or simply overrides.

Set option

The Helm --set option provides parameter values directly on the CLI. For example:

helm install release chart --set app.name=test-app --set spec.ip=10.244.100.1 \
--set spec.port=80

Values file

When a Helm chart has many template directives, it may be easier to set the values in a YAML file, and reference the file using the -f option. For example:

  1. Add the parameters and values to the values.yaml file:

    app:
      name: test-app
    spec:
      ip: 10.244.100.1
      port: 80
    
  2. Reference the file when using the Helm CLI:

    helm install release_name chart -f values.yaml
    

Requirements

Ensure you have:

Procedure

  1. Create a new Helm chart named cr-demo:

    helm create cr-demo
    
  2. Change into the cr-demo directory:

    cd cr-demo
    
  3. Edit the Chart.yaml file to better describe the application:

    apiVersion: v2
    name: cr-demo
    description: Integrating Nginx app and F5SPKIngressTCP CR
    
    type: application
    version: 0.1.0
    appVersion: "1.14.2"
    
  4. Remove the default templates:

    rm -rf templates/*
    
  5. Create an Nginx Deployment template named spk-nginx-deploy.yaml using the code below, or download the file here:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: {{ .Values.nginx.name }}
      namespace: {{ .Release.Namespace }}
    spec:
      selector:
        matchLabels:
          app: {{ .Values.nginx.name }}
      replicas: {{ .Values.nginx.replicas }}
      template:
        metadata:
          labels:
            app: {{ .Values.nginx.name }}
        spec:
          containers:
          - name: {{ .Values.nginx.image.name }}
            image: "{{ .Values.nginx.image.name }}:{{ .Values.nginx.image.version }}"
    
  6. Create an Nginx Service template named spk-nginx-service.yaml using the code below, or download the file here:

    apiVersion: v1
    kind: Service
    metadata:
      name: {{ .Values.nginx.name }}
      namespace: {{ .Release.Namespace }}
      labels:
        app: {{ .Values.nginx.name }}
    spec:
      type: NodePort
      selector:
        app: {{ .Values.nginx.name }}
      ports:
      - port: {{ .Values.service.port }}
        targetPort: {{ .Values.service.targetPort }}
        protocol: TCP
    
  7. Create an F5SPKIngressTCP CR template named spk-nginx-cr.yaml using the code below, or download the file here:

    _images/spk_info.png Note: The if statements allow you to pass IPv4 or IPv6 address values.

    apiVersion: "ingresstcp.k8s.f5net.com/v1"
    kind: F5SPKIngressTCP
    metadata:
      name: {{ .Values.cr.name }}
      namespace: {{ .Release.Namespace }}
    service:
      name: {{ .Values.nginx.name }}
      port: {{ .Values.service.port }}
    spec:
    {{- if .Values.cr.dstIPv4 }}
      destinationAddress: {{ .Values.cr.dstIPv4 }}
    {{- end }}
    {{- if .Values.cr.dstIPv6 }}
      ipv6destinationAddress: {{ .Values.cr.dstIPv6 }}
    {{- end }}
      destinationPort: {{ .Values.cr.dstPort }}
    
  8. The templates directory should now contain the following files:

    ls -1 templates/
    
    spk-nginx-cr.yaml
    spk-nginx-deploy.yaml
    spk-nginx-service.yaml
    
  9. Create a Helm values file named nginx-values.yaml, or download the file here:

    # The nginx deployment values
    nginx:
      name: nginx-app
      replicas: 3
      image:
        name: nginx
        version: 1.14.2
    
    # The service object values
    service:
      port: 80
      targetPort: 80
    
    # The F5SPKIngressTCP CR values
    cr:
      name: nginx-cr
      dstIPv4: "10.10.10.1"
      dstIPv6: "2002::10:10:10:1"
      dstPort: 80
    
  10. Install the application (Deployment, Service, and F5SPKIngressTCP) using Helm:

    _images/spk_info.png Note: A Helm installation is referred to as a release.

    helm install <release name> ../cr-demo -f <values file> -n <project>
    

    In this example, the release named nginx-app uses the nginx-values.yaml values file, and installs to the tcp-apps Project:

    helm install nginx-app ../cr-demo -f nginx-values.yaml -n tcp-apps
    
  11. Verify the Helm release:

    helm list -n tcp-apps
    
    NAME        NAMESPACE    REVISION    STATUS     CHART            APP VERSION
    nginx-app   tcp-apps     1           deployed   cr-demo-0.1.0   1.14.2
    
  12. Verify the Kubernetes objects:

    oc get deploy,service,f5-spk-ingresstcp -n tcp-apps
    
    NAME                        READY   UP-TO-DATE   AVAILABLE   
    deployment.apps/nginx-app   3/3     3            3          
    
    NAME                TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)       
    service/nginx-app   NodePort   10.100.226.178   <none>        80:31718/TCP  
    
    NAME                                         
    f5spkingresstcp.ingresstcp.k8s.f5net.com/nginx-cr