我想通过kubectl api创建一个秘密。 下面是脚本,我正在运行,但在解析yaml文件时出现错误。 请帮助
{ TranscriptionJob:
{ TranscriptionJobName: 'file1',
TranscriptionJobStatus: 'COMPLETED',
LanguageCode: 'en-US',
MediaSampleRateHertz: 44100,
MediaFormat: 'mp3',
Media:
{ MediaFileUri: 'https://s3.amazonaws.com/mybucket/2+Testimonies-+Week+1.mp3' },
Transcript:
{ TranscriptFileUri: 'https://s3.amazonaws.com/aws-transcribe-us-east-1-prod/4379/file1/asrOutput.json?X-Amz-Security-Token=secretstuff' },
CreationTime: 2018-06-28T18:02:05.614Z,
CompletionTime: 2018-06-28T18:06:07.077Z } }
错误:
message”:“提供的对象无法识别(必须是Secret类型):无法获得版本/种类; json解析错误:无效字符'}'寻找对象关键字字符串的开头({\“ apiVersion \”:\“ v1 \”,\“ kind \”:\“ S ...)”, “ reason”:“ BadRequest”,
答案 0 :(得分:0)
我更改了json结构,在其中添加了结尾的大括号和类型键中的一个逗号。
curl -vk \
-X POST \
-d @- \
-H "Authorization: Bearer $(cat token)" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
https://192.168.2.100:6443/api/v1/namespaces/nginx-ingress/secrets <<'EOF'
{
"apiVersion":"v1",
"kind" :"Secret",
"metadata" :{"namespace" :"nginx-ingress","name":"mysecret1"},
"type": "Opaque",
"data": {"username": "YWRtaW4=","password": "MWYyZDFlMmU2N2Rm"}
}
有效。