Puppet Function: cd4peadm::kubectl

Defined in:
functions/kubectl.pp
Function type:
Puppet Language

Overview

cd4peadm::kubectl(TargetSpec $cd4pe_4_target, String $command)ResultSet

Invokes ‘kubectl` using the namespace specified in vars on the target. Also sets the `KUBECONFIG` env var based on the host’s value.

Parameters:

  • $cd4pe_4_target (TargetSpec)

    the target to run kubectl on

  • $command (String)

    the command to run via ‘kubectl`. Can also include piping to other commands.

  • cd4pe_4_target (TargetSpec)
  • command (String)

Returns:

  • (ResultSet)

    the ResultSet from the command



8
9
10
11
12
13
14
15
16
17
# File 'functions/kubectl.pp', line 8

function cd4peadm::kubectl(TargetSpec $cd4pe_4_target, String $command) >> ResultSet {
  $kubernetes_namespace = cd4peadm::default_for_value($cd4pe_4_target.vars['kubernetes_namespace'], 'default')
  $kubeconfig_env_var = { 'KUBECONFIG' => system::env('KUBECONFIG') }

  run_command(
    "kubectl -n ${kubernetes_namespace} ${command}",
    $cd4pe_4_target,
    { '_env_vars' => $kubeconfig_env_var }
  )
}