我按照指南将数据库连接到kubernetes:https://itnext.io/basic-postgres-database-in-kubernetes-23c7834d91ef
在Windows1064位上安装Kubernetes (minikube)后:https://minikube.sigs.k8s.io/docs/start/
我遇到了一个问题'base64‘,其中DB正在试图连接和存储密码。因为PowerShell没有意识到。我想知道是否有人知道我怎样才能修复这个问题,并且仍然使用windows或其他方法,使我能够继续使用指南的其余部分?
错误代码:
base64 : The term 'base64' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:131
+ ... postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decod ...
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (base64:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
export : The term 'export' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ export POSTGRES_PASSWORD=$(kubectl get secret --namespace default pos ...
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (export:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
发布于 2022-01-14 12:56:36
在Mac和一些*nix发行版中发现的base64
cli在Windows上不可用。
您可以编写一个名为base64
的小函数,它模仿base64
unix工具的行为:
function base64 {
# enumerate all pipeline input
$input |ForEach-Object {
if($MyInvocation.UnboundArguments -contains '--decode'){
# caller supplied `--decode`, so decode
$bytes = [convert]::FromBase64String($_)
[System.Text.Encoding]::ASCII.GetString($bytes)
} else {
# default mode, encode ascii text as base64
$bytes = [System.Text.Encoding]::ASCII.GetBytes($_)
[convert]::ToBase64String($bytes)
}
}
}
这应该作为ASCII/UTF7 7文本和base64之间转换的插入替代:
PS ~> 'Hello, World!' |base64 --encode
SGVsbG8sIFdvcmxkIQ==
PS ~> 'Hello, World!' |base64 --encode |base64 --decode
Hello, World!
要与现有脚本一起使用,在执行其他脚本之前,简单的点源脚本具有shell中的函数定义:
PS ~> . .\path\to\base64.ps1
上面的工作也将从一个脚本。如果您有一个多行的粘贴感知外壳( PSReadLine的默认控制台主机应该可以),也可以直接将函数定义粘贴到提示符中:)
发布于 2022-01-14 16:46:36
您正在尝试在Windows上执行命令行,这些命令行是为类似Unix的平台编写的,这两个命令行的内容如下:
base64
)export POSTGRES_PASSWORD=$(...)
;为与POSIX兼容的shell(如bash
)编写的)。Mathias的有用答案向您展示了如何在PowerShell中模拟base64
实用程序,您甚至可以通过额外的、非平凡的工作来模拟export
shell命令,但并不是所有情况都可以这样处理,例如使用\"
来转义"
字符的命令行(这将破坏PowerShell的语法,尝试echo "3\" of snow."
)。
因此,我建议在可行的情况下通过WSL运行命令,或者花时间将命令行转换为PowerShell--本机等效的命令行。
https://stackoverflow.com/questions/70710764
复制相似问题