vault write command using shell script

7/9/2021

I am trying to use vault in shell script using below commands.

    export k8s_host="$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ")"
    export secret_name="$(kubectl get serviceaccount vault-auth -n vault -o go-template='{{ (index .secrets 0).name }}')"
    export tr_account_token="$(kubectl get secret ${secret_name} -n vault -o go-template='{{ .data.token }}' | base64 --decode)"
    export k8s_cacert="$(kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}' | base64 --decode)"
    vault write auth/eks-clustrname-k8s-cluster-kubernetes/config token_reviewer_jwt="${tr_account_token}" kubernetes_host="${k8s_host}" kubernetes_ca_cert="${k8s_cacert}"

But it gives me error vault: command not found Can someone guide me how to fix this??

-- knowledge20
amazon-eks
hashicorp-vault
kubernetes
shell
vault

1 Answer

7/9/2021

You need to install and configure Vault following the instructions of your platform:

https://www.vaultproject.io/downloads

-- Marcelo Ávila de Oliveira
Source: StackOverflow