Skip to content

Commit

Permalink
fix: depecrate --ssh-add flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeProgrammer committed Sep 27, 2023
1 parent f23902c commit d0f350e
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 34 deletions.
61 changes: 31 additions & 30 deletions cmd/minikube/cmd/docker-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type DockerShellConfig struct {
var (
noProxy bool
sshHost bool
sshAdd bool
sshAdd bool // deprecated
dockerUnset bool
defaultNoProxyGetter NoProxyGetter
)
Expand Down Expand Up @@ -271,6 +271,10 @@ For example, you can do all docker operations such as docker build, docker run,
Note: You need the docker-cli to be installed on your machine.
docker-cli install instructions: https://minikube.sigs.k8s.io/docs/tutorials/docker_desktop_replacement/#steps`,
Run: func(cmd *cobra.Command, args []string) {

if sshAdd {
out.WarningT("--ssh-add flag has been deprecated, please user --ssh-host instead. Now if you use --ssh-host to enable ssh connection with docker, minikube will automatically add ssh-agent and append hosts to known_hosts")
}
var err error

shl := shell.ForceShell
Expand Down Expand Up @@ -326,7 +330,11 @@ docker-cli install instructions: https://minikube.sigs.k8s.io/docs/tutorials/doc
// so directly set --ssh-host --ssh-add to true, even user didn't specify them
sshAdd = true
sshHost = true
}

d := co.CP.Host.Driver

if sshHost || sshAdd {
// start the ssh-agent
if err := sshagent.Start(cname); err != nil {
exit.Message(reason.SSHAgentStart, err.Error())
Expand All @@ -338,6 +346,27 @@ docker-cli install instructions: https://minikube.sigs.k8s.io/docs/tutorials/doc
// set the ssh-agent envs for current process
os.Setenv("SSH_AUTH_SOCK", co.Config.SSHAuthSock)
os.Setenv("SSH_AGENT_PID", strconv.Itoa(co.Config.SSHAgentPID))

klog.Infof("Adding %v", d.GetSSHKeyPath())

path, err := exec.LookPath("ssh-add")
if err != nil {
exit.Error(reason.IfSSHClient, "Error with ssh-add", err)
}
cmd := exec.Command(path, d.GetSSHKeyPath())
cmd.Stderr = os.Stderr

cmd.Env = append(cmd.Env, fmt.Sprintf("SSH_AUTH_SOCK=%s", co.Config.SSHAuthSock))
cmd.Env = append(cmd.Env, fmt.Sprintf("SSH_AGENT_PID=%d", co.Config.SSHAgentPID))

err = cmd.Run()
if err != nil {
exit.Error(reason.IfSSHClient, "Error with ssh-add", err)
}

// if we use ssh to connect the docker daemon, appending know is always required
// eventually, run something similar to ssh --append-known
appendKnownHelper(nodeName, true)
}

r := co.CP.Runner
Expand All @@ -346,7 +375,6 @@ docker-cli install instructions: https://minikube.sigs.k8s.io/docs/tutorials/doc
ensureDockerd(cname, r)
}

d := co.CP.Host.Driver
port := constants.DockerDaemonPort
if driver.NeedsPortForward(driverName) {
port, err = oci.ForwardedPort(driverName, cname, port)
Expand Down Expand Up @@ -404,33 +432,6 @@ docker-cli install instructions: https://minikube.sigs.k8s.io/docs/tutorials/doc
if err := dockerSetScript(ec, os.Stdout); err != nil {
exit.Error(reason.InternalDockerScript, "Error generating set output", err)
}

if sshAdd {
klog.Infof("Adding %v", d.GetSSHKeyPath())

path, err := exec.LookPath("ssh-add")
if err != nil {
exit.Error(reason.IfSSHClient, "Error with ssh-add", err)
}
cmd := exec.Command(path, d.GetSSHKeyPath())
cmd.Stderr = os.Stderr

// TODO: refactor to work with docker, temp fix to resolve regression
if cr == constants.Containerd {
cmd.Env = append(cmd.Env, fmt.Sprintf("SSH_AUTH_SOCK=%s", co.Config.SSHAuthSock))
cmd.Env = append(cmd.Env, fmt.Sprintf("SSH_AGENT_PID=%d", co.Config.SSHAgentPID))
}
err = cmd.Run()
if err != nil {
exit.Error(reason.IfSSHClient, "Error with ssh-add", err)
}

// TODO: refactor to work with docker, temp fix to resolve regression
if cr == constants.Containerd {
// eventually, run something similar to ssh --append-known
appendKnownHelper(nodeName, true)
}
}
},
}

Expand Down Expand Up @@ -692,7 +693,7 @@ func init() {
defaultNoProxyGetter = &EnvNoProxyGetter{}
dockerEnvCmd.Flags().BoolVar(&noProxy, "no-proxy", false, "Add machine IP to NO_PROXY environment variable")
dockerEnvCmd.Flags().BoolVar(&sshHost, "ssh-host", false, "Use SSH connection instead of HTTPS (port 2376)")
dockerEnvCmd.Flags().BoolVar(&sshAdd, "ssh-add", false, "Add SSH identity key to SSH authentication agent")
dockerEnvCmd.Flags().BoolVar(&sshAdd, "ssh-add", false, "Deprecated: Add SSH identity key to SSH authentication agent")
dockerEnvCmd.Flags().StringVar(&shell.ForceShell, "shell", "", "Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, bash, zsh], default is auto-detect")
dockerEnvCmd.Flags().StringVarP(&outputFormat, "output", "o", "", "One of 'text', 'yaml' or 'json'.")
dockerEnvCmd.Flags().BoolVarP(&dockerUnset, "unset", "u", false, "Unset variables instead of setting them")
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/commands/docker-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ minikube docker-env [flags]
--no-proxy Add machine IP to NO_PROXY environment variable
-o, --output string One of 'text', 'yaml' or 'json'.
--shell string Force environment to be configured for a specified shell: [fish, cmd, powershell, tcsh, bash, zsh], default is auto-detect
--ssh-add Add SSH identity key to SSH authentication agent
--ssh-add Deprecated: Add SSH identity key to SSH authentication agent
--ssh-host Use SSH connection instead of HTTPS (port 2376)
-u, --unset Unset variables instead of setting them
```
Expand Down
2 changes: 2 additions & 0 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"--network flag is only valid with the docker/podman and KVM drivers, it will be ignored": "Der Parameter --network kann nur mit dem docker/podman und den KVM Treibern verwendet werden, er wird ignoriert werden",
"--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "",
"--network with QEMU must be 'builtin' or 'socket_vmnet'": "",
"--ssh-add flag has been deprecated, please user --ssh-host instead. Now if you use --ssh-host to enable ssh connection with docker, minikube will automatically add ssh-agent and append hosts to known_hosts": "",
"--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "",
"--static-ip overrides --subnet, --subnet will be ignored": "",
"1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "1) Erstellen Sie den Cluster mit Kubernetes {{.new}} neu, indem Sie folgende Befehle ausführen:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Erstellen Sie einen zweiten Cluster mit Kubernetes {{.new}}, indem Sie folgende Befehle ausführen:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Verwenden Sie den existierenden Cluster mit Version {{.old}} von Kubernetes, indem Sie folgende Befehle ausführen:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t",
Expand Down Expand Up @@ -150,6 +151,7 @@
"Deleting container \"{{.name}}\" ...": "Lösche Container \"{{.name}}\" ...",
"Deleting existing cluster {{.name}} with different driver {{.driver_name}} due to --delete-on-failure flag set by the user. ": "Lösche den existierenden Cluster {{.name}} mit unterschiedlichem Treiber {{.driver_name}} aufgrund des vom Benutzer gesetzten --delete-on-failure Parameters. ",
"Deleting node {{.name}} from cluster {{.cluster}}": "Lösche Node {{.name}} von Cluster {{.cluster}}",
"Deprecated: Add SSH identity key to SSH authentication agent": "",
"Directory to output licenses to": "",
"Disable checking for the availability of hardware virtualization before the vm is started (virtualbox driver only)": "Deaktivieren Sie die Überprüfung der Verfügbarkeit der Hardwarevirtualisierung vor dem Starten der VM (nur Virtualbox-Treiber)",
"Disable dynamic memory in your VM manager, or pass in a larger --memory value": "Deaktiveren Sie die dynmaische Memory-Verwaltung in ihrem VM manager oder verwenden Sie einen größeren --memory Wert",
Expand Down
2 changes: 2 additions & 0 deletions translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"--network flag is only valid with the docker/podman and KVM drivers, it will be ignored": "el flag --network es válido solamente con docker/podman y KVM, será ignorado",
"--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "",
"--network with QEMU must be 'builtin' or 'socket_vmnet'": "",
"--ssh-add flag has been deprecated, please user --ssh-host instead. Now if you use --ssh-host to enable ssh connection with docker, minikube will automatically add ssh-agent and append hosts to known_hosts": "",
"--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "",
"--static-ip overrides --subnet, --subnet will be ignored": "",
"1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "",
Expand Down Expand Up @@ -154,6 +155,7 @@
"Deleting container \"{{.name}}\" ...": "Eliminando contenedor \"{{.name}}\" ...",
"Deleting existing cluster {{.name}} with different driver {{.driver_name}} due to --delete-on-failure flag set by the user. ": "",
"Deleting node {{.name}} from cluster {{.cluster}}": "Eliminando nodo {{.name}} del clúster {{.cluster}}",
"Deprecated: Add SSH identity key to SSH authentication agent": "",
"Directory to output licenses to": "",
"Disable checking for the availability of hardware virtualization before the vm is started (virtualbox driver only)": "Permite inhabilitar la comprobación de disponibilidad de la virtualización de hardware antes de iniciar la VM (solo con el controlador de Virtualbox)",
"Disable dynamic memory in your VM manager, or pass in a larger --memory value": "Desactivar memoria dinámica in tu administrador de VM, o pasa un mayor valor --memory",
Expand Down
2 changes: 2 additions & 0 deletions translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "L'indicateur --network n'est valide qu'avec les pilotes docker/podman, KVM et Qemu, il sera ignoré",
"--network with QEMU must be 'builtin' or 'socket_vmnet'": "--network avec QEMU doit être 'builtin' ou 'socket_vmnet'",
"--network with QEMU must be 'user' or 'socket_vmnet'": "--network avec QEMU doit être 'user' ou 'socket_vmnet'",
"--ssh-add flag has been deprecated, please user --ssh-host instead. Now if you use --ssh-host to enable ssh connection with docker, minikube will automatically add ssh-agent and append hosts to known_hosts": "",
"--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "--static-ip n'est implémenté que sur les pilotes Docker et Podman, l'indicateur sera ignoré",
"--static-ip overrides --subnet, --subnet will be ignored": "--static-ip remplace --subnet, --subnet sera ignoré",
"1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete {{.profile}}\n\t\t minikube start {{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start {{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "1) Recréez le cluster avec Kubernetes {{.new}}, en exécutant :\n\t \n\t\t minikube delete {{.profile}}\n\t\t minikube start {{.profile}} - -kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Créez un deuxième cluster avec Kubernetes {{.new}}, en exécutant :\n\t \n \t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Utiliser le cluster existant à la version Kubernetes {{.old}}, en exécutant :\n\t \n\t\t minikube start {{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t \t",
Expand Down Expand Up @@ -155,6 +156,7 @@
"Deleting container \"{{.name}}\" ...": "Suppression du conteneur \"{{.name}}\" ...",
"Deleting existing cluster {{.name}} with different driver {{.driver_name}} due to --delete-on-failure flag set by the user. ": "Suppression du cluster existant {{.name}} avec un pilote différent {{.driver_name}} en raison de l'indicateur --delete-on-failure défini par l'utilisateur.",
"Deleting node {{.name}} from cluster {{.cluster}}": "Suppression de noeuds {{.name}} de cluster {{.cluster}}",
"Deprecated: Add SSH identity key to SSH authentication agent": "",
"Directory to output licenses to": "Répertoire de sortie des licences",
"Disable checking for the availability of hardware virtualization before the vm is started (virtualbox driver only)": "Désactive la vérification de la disponibilité de la virtualisation du matériel avant le démarrage de la VM (pilote virtualbox uniquement).",
"Disable dynamic memory in your VM manager, or pass in a larger --memory value": "Désactivez la mémoire dynamique dans votre gestionnaire de machine virtuelle ou transmettez une valeur --memory plus grande",
Expand Down
2 changes: 2 additions & 0 deletions translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "--network フラグは、docker/podman, KVM および Qemu ドライバーでのみ有効であるため、無視されます",
"--network with QEMU must be 'builtin' or 'socket_vmnet'": "QEMU を用いる場合、--network は、'builtin' か 'socket_vmnet' でなければなりません",
"--network with QEMU must be 'user' or 'socket_vmnet'": "QEMU を用いる場合、--network は、'user' か 'socket_vmnet' でなければなりません",
"--ssh-add flag has been deprecated, please user --ssh-host instead. Now if you use --ssh-host to enable ssh connection with docker, minikube will automatically add ssh-agent and append hosts to known_hosts": "",
"--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "--static-ip フラグは、Docker および Podman ドライバー上でのみ実装されているため、無視されます",
"--static-ip overrides --subnet, --subnet will be ignored": "--static-ip は --subnet をオーバーライドし、--subnet は無視されます",
"1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "1) 次のコマンドで Kubernetes {{.new}} によるクラスターを再構築します:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) 次のコマンドで Kubernetes {{.new}} による第 2 のクラスターを作成します:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) 次のコマンドで Kubernetes {{.old}} による既存クラスターを使用します:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t",
Expand Down Expand Up @@ -145,6 +146,7 @@
"Deleting container \"{{.name}}\" ...": "コンテナー「{{.name}}」を削除しています...",
"Deleting existing cluster {{.name}} with different driver {{.driver_name}} due to --delete-on-failure flag set by the user. ": "ユーザーが設定した --delete-on-failure フラグにより、異なるドライバー {{.driver_name}} を持つ既存のクラスター {{.name}} を削除しています。",
"Deleting node {{.name}} from cluster {{.cluster}}": "クラスター {{.cluster}} から、ノード {{.name}} を削除しています",
"Deprecated: Add SSH identity key to SSH authentication agent": "",
"Directory to output licenses to": "ライセンスを出力するディレクトリー",
"Disable checking for the availability of hardware virtualization before the vm is started (virtualbox driver only)": "VM が起動する前にハードウェアの仮想化の可用性チェックを無効にします (virtualbox ドライバーのみ)",
"Disable dynamic memory in your VM manager, or pass in a larger --memory value": "VM マネージャーで動的メモリーを無効にするか、より大きな --memory の値を指定してください",
Expand Down
2 changes: 2 additions & 0 deletions translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"--kvm-numa-count range is 1-8": "--kvm-numa-count 범위는 1부터 8입니다",
"--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored": "--network 는 docker나 podman 에서만 유효합니다. KVM이나 Qemu 드라이버에서는 인자가 무시됩니다",
"--network with QEMU must be 'builtin' or 'socket_vmnet'": "",
"--ssh-add flag has been deprecated, please user --ssh-host instead. Now if you use --ssh-host to enable ssh connection with docker, minikube will automatically add ssh-agent and append hosts to known_hosts": "",
"--static-ip is only implemented on Docker and Podman drivers, flag will be ignored": "",
"--static-ip overrides --subnet, --subnet will be ignored": "",
"1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "",
Expand Down Expand Up @@ -161,6 +162,7 @@
"Deleting container \"{{.name}}\" ...": "",
"Deleting existing cluster {{.name}} with different driver {{.driver_name}} due to --delete-on-failure flag set by the user. ": "",
"Deleting node {{.name}} from cluster {{.cluster}}": "클러스터 {{.cluster}} 에서 노드 {{.name}} 를 삭제하는 중 ...",
"Deprecated: Add SSH identity key to SSH authentication agent": "",
"Directory to output licenses to": "",
"Disable checking for the availability of hardware virtualization before the vm is started (virtualbox driver only)": "가상 머신 시작 전 하드웨어 가상화 지원 여부 확인 작업을 비활성화합니다 (virtualbox 드라이버 한정)",
"Disable dynamic memory in your VM manager, or pass in a larger --memory value": "",
Expand Down
Loading

0 comments on commit d0f350e

Please sign in to comment.