Manage TLS certificates with Let's Encrypt

Automate TLS certificate management for Splunk ingress using Let's Encrypt.

Use cert-manager with Let's Encrypt to manage TLS certificates for Splunk components in Kubernetes.

Example configuration for NGINX

The following Ingress object enables secure (TLS) access to all Splunk components from outside of your Kubernetes cluster:

CODE
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: splunk-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/affinity: cookie
    certmanager.k8s.io/cluster-issuer: "letsencrypt-prod"
spec:
  rules:
  - host: splunk.example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: splunk-example-search-head-service
          servicePort: 8000
      - path: /services/collector
        backend:
          serviceName: splunk-example-indexer-service
          servicePort: 8088
  - host: deployer.splunk.example.com
    http:
      paths:
      - backend:
          serviceName: splunk-example-deployer-service
          servicePort: 8000
  - host: cluster-manager.splunk.example.com
    http:
      paths:
      - backend:
          serviceName: splunk-example-cluster-manager-service
          servicePort: 8000
  - host: license-manager.splunk.example.com
    http:
      paths:
      - backend:
          serviceName: splunk-example-license-manager-service
          servicePort: 8000
  tls:
  - hosts:
    - splunk.example.com
    - deployer.splunk.example.com
    - cluster-manager.splunk.example.com
    - license-manager.splunk.example.com
    secretName: splunk.example.com-tls

The certmanager.k8s.io/cluster-issuer annotation is optional and is used to automatically create and manage certificates. You can change it to match your Issuer.

If you are not using cert-manager, remove this annotation and update the tls section as appropriate. If you are manually importing your certificates into separate secrets for each host name, reference these by using multiple tls objects in your Ingress:

CODE
tls:
  - hosts:
    - splunk.example.com
    secretName: splunk.example.com-tls
  - hosts:
    - deployer.splunk.example.com
    secretName: deployer.splunk.example.com-tls
  - hosts:
    - cluster-manager.splunk.example.com
    secretName: cluster-manager.splunk.example.com-tls

Example configuration for Istio

If you are using cert-manager with Let's Encrypt to manage your TLS certificates in Kubernetes:

  1. Create the Certificate object and populate a splunk-example-com-tls secret in the istio-system namespace:
    CODE
    apiVersion: certmanager.k8s.io/v1alpha1
    kind: Certificate
    metadata:
      name: splunk-example-com-cert
      namespace: istio-system
    spec:
      secretName: splunk-example-com-tls
      commonName: splunk.example.com
      dnsNames:
        - splunk.example.com
        - deployer.splunk.example.com
        - cluster-manager.splunk.example.com
        - license-manager.splunk.example.com
      issuerRef:
        name: letsencrypt-prod
        kind: ClusterIssuer
  2. Create an Istio Gateway that is associated with your certificates:
    CODE
    apiVersion: networking.istio.io/v1beta1
    kind: Gateway
    metadata:
      name: splunk-gw
    spec:
      selector:
        istio: ingressgateway
      servers:
      - port:
          number: 80
          name: http
          protocol: HTTP
        hosts:
        - "splunk.example.com"
        - "deployer.splunk.example.com"
        - "cluster-manager.splunk.example.com"
        - "license-manager.splunk.example.com"
        tls:
          httpsRedirect: true
      - port:
          number: 443
          name: https
          protocol: HTTPS
        tls:
          mode: SIMPLE
          credentialName: "splunk-example-com-tls"
        hosts:
        - "splunk.example.com"
        - "deployer.splunk.example.com"
        - "cluster-manager.splunk.example.com"
        - "license-manager.splunk.example.com"

    The credentialName references the same secretName created and managed by the Certificate object.

  3. If you are manually importing your certificates into separate secrets for each host name, reference these by instead using multiple port objects in your Gateway:
    CODE
    - port:
        number: 443
        name: https
        protocol: HTTPS
      tls:
        mode: SIMPLE
        credentialName: "splunk-example-com-tls"
      hosts:
      - "splunk.example.com"
    - port:
        number: 443
        name: https
        protocol: HTTPS
      tls:
        mode: SIMPLE
        credentialName: "deployer-splunk-example-com-tls"
      hosts:
      - "deployer.splunk.example.com"
  4. Create VirtualServices for each of the components that you want to expose outside of Kubernetes:
    CODE
    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
      name: splunk
    spec:
      hosts:
      - "splunk.example.com"
      gateways:
      - "splunk-gw"
      http:
      - match:
        - uri:
            prefix: "/services/collector"
        route:
        - destination:
            port:
              number: 8088
            host: splunk-example-indexer-service
      - route:
        - destination:
            port:
              number: 8000
            host: splunk-example-search-head-service
    ---
    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
      name: splunk-deployer
    spec:
      hosts:
      - "deployer.splunk.example.com"
      gateways:
      - "splunk-gw"
      http:
      - route:
        - destination:
            port:
              number: 8000
            host: splunk-example-deployer-service
    ---
    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
      name: splunk-cluster-manager
    spec:
      hosts:
      - "cluster-manager.splunk.example.com"
      gateways:
      - "splunk-gw"
      http:
      - route:
        - destination:
            port:
              number: 8000
            host: splunk-example-cluster-manager-service
    ---
    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
      name: splunk-license-manager
    spec:
      hosts:
      - "license-manager.splunk.example.com"
      gateways:
      - "splunk-gw"
      http:
      - route:
        - destination:
            port:
              number: 8000
            host: splunk-example-license-manager-service
  5. Create a DestinationRule to ensure user sessions are sticky to specific search heads:
    CODE
    apiVersion: networking.istio.io/v1beta1
    kind: DestinationRule
    metadata:
      name: splunk-search-head-rule
    spec:
      host: splunk-example-search-head-service
      trafficPolicy:
        loadBalancer:
          consistentHash:
            httpCookie:
              name: SPLUNK_ISTIO_SESSION
              ttl: 3600s