Manage global Kubernetes secret object

Manage the global Kubernetes secret object for Splunk deployments.

Create, read, update, and delete the global Kubernetes secret object used for Splunk Enterprise deployments.

Create the global Kubernetes secret object

Use the kubectl command to create the global Kubernetes secret object:

  1. Verify the namespace. Retrieve the namespace in the current context using the following command:
    CODE
    kubectl config view --minify --output 'jsonpath={..namespace}'

    Make a note of the output. If the command does not display output, you are in the default namespace.

    Note: If you already have a desired namespace, set the current context to that namespace using the following command:
    CODE
    kubectl config set-context --current --namespace=<desired_namespace>
  2. Gather the password values for the secret tokens you want to configure. To see all available secret tokens defined for the global Kubernetes secret object, review the password management documentation.
  3. Create a Kubernetes secret object referencing the namespace. The following example creates the global Kubernetes secret object with the default administrator and pass4SymmKey tokens:
    CODE
    kubectl create secret generic splunk-<desired_namespace>-secret \
      --from-literal='password=<admin_password_value>' \
      --from-literal='pass4SymmKey=<pass4Symmkey_value>'

Read the global Kubernetes secret object

Once created, all secret tokens in the secret object are base64 encoded. To read the global Kubernetes secret object, run the following command:

CODE
kubectl get secret splunk-<desired_namespace>-secret -o yaml

A sample global Kubernetes secret object with base64 encoded values:

CODE
kubectl get secret splunk-default-secret -o yaml
apiVersion: v1
data:
  hec_token: RUJFQTE4OTMtMDI4My03RkMzLThEQTAtQ0I1RTFGQzgzMzc1
  idxc_secret: VUY5dWpHU1I4ZmpoZlJKaWNNT2VMSUNY
  pass4SymmKey: dkFjelZSUzJjZzFWOHZPaVRGZk9hSnYy
  password: OHFqcnV5WFhHRFJXU1hveDdZMzY5MGRs
  shc_secret: ZEdHWG5Ob2dzTDhWNHlocDFiYWpiclo1
kind: Secret
metadata:
  creationTimestamp: "2020-10-07T19:42:07Z"
  name: splunk-default-secret
  namespace: splunk-operator
  resourceVersion: "11433590"
  uid: d6c9a59c-1acf-4482-9990-cdb0eed56e87
type: Opaque

Use the kubectl command line tool to decode the Splunk secret tokens with the following command:

JSON
kubectl get secret splunk-<desired_namespace>-secret -o go-template='{{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}'

A sample global Kubernetes secret object with tokens decoded:

CODE
hec_token: EBEA1893-0283-7FC3-8DA0-CB5E1FC83375
idxc_secret: UF9ujGSR8fjhfRJicMOeLICX
pass4SymmKey: vAczVRS2cg1V8vOiTFfOaJv2
password: 8qjruyXXGDRWSXox7Y3690dl
shc_secret: dGGXnNogsL8V4yhp1bajbrZ5

Update the global Kubernetes secret object

Use the kubectl command to update the global Kubernetes secret object:

  1. Base64 encode the plain-text value of the secret token:
    CODE
    echo -n <plain_text_value> | base64
  2. Obtain the key name for the secret token you are populating. The list of tokens is available in the password management documentation.
  3. Update the global Kubernetes secret object using the key and the encoded value:
    JSON
    kubectl patch secret splunk-<desired_namespace>-secret \
      -p='{"data":{"<key_name_for_secret_token>": "<encoded_value>"}}' -v=1

Delete the global Kubernetes secret object

Use the kubectl command to delete the global Kubernetes secret object:

CODE
kubectl delete secret splunk-<desired_namespace>-secret