我們正在嘗試使用,并且我們希望保留敏感數據,例如在github內部,我創建了一個帶有名稱的GitHub秘密github actionskubeconfigsecretsKUBECONFIG1重現步驟在GitHub秘密中,我應該存儲以下文件,也嘗試使用此 https://onlineyamltools.com/convert-yaml-to-jsonapiVersion: v1kind: Configclusters: - name: brf cluster: certificate-authority-data: >- LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURTakNBd0t6RXBNQ2NHQTFVRUF4TWdkbWx5ZE2bUljTlRtakFWCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0= server: 'https://vfg.canary.k8s.ondemand.com'users: - name: user1 user: token: >- eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuW1lc3BhY2UiOiJnYXJkZW4tZGV2econtexts: - name: g-root context: cluster: garv user: robot namespace: gkingcurrent-context: gaot在github操作工作流程中,我們將上面的文件內容與名稱一起保存,并從中創建k8s秘密。KUBECONFIG1name: Example actionon: [push]jobs: build: runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v2 - name: install k8s run: | curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE=777 sh - cat /etc/rancher/k3s/k3s.yaml mkdir -p ~/.kube cp /etc/rancher/k3s/k3s.yaml ~/.kube/config - run: 'echo -e "$KUBECONFIG1" > ~/.tmpfile.json' shell: bash env: KUBECONFIG1: ${{secrets.KUBECONFIG1}} - name: example shell: bash run: | cd ~/ kubectl create secret generic project-kubecfg --from-file=~/.tmpfile.json -n default運行此工作流后,我收到以下錯誤:error: error loading config file "/home/runner/work/_temp/kubeconfig_1617030542039": couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct *** APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" ***Error: Process completed with exit code 1.
1 回答

慕容森
TA貢獻1853條經驗 獲得超18個贊
問題出在以下命令上
kubectl create secret generic project-kubecfg --from-file=~/.tmpfile.json -n default
問題是轉到哪個不會將其擴展到主目錄。因此,如果您像下面那樣更改它,它將起作用~
kubectl
kubectl create secret generic project-kubecfg --from-file=/home/runner/.tmpfile.json -n default
或者更確切地說,使用固定路徑而不是主目錄~
- 1 回答
- 0 關注
- 137 瀏覽
添加回答
舉報
0/150
提交
取消