From e78501252569fcbdfbcd835b1d6c778a4eb3e14d Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 10 Apr 2020 08:19:14 -0500 Subject: [PATCH 01/31] add registery port constant --- pkg/minikube/constants/constants.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index 7917b0e7aafd..255ee134d517 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -40,6 +40,8 @@ const ( APIServerPort = 8443 // SSHPort is the SSH serviceport on the node vm and container SSHPort = 22 + // RegisteryAddonPort os the default registery addon port + RegisteryAddonPort = 5000 // APIServerName is the default API server name APIServerName = "minikubeCA" From 50c2ec4eaf412bd6520e18a0a717cbf668b11a5c Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 10 Apr 2020 08:20:12 -0500 Subject: [PATCH 02/31] add oci port mapping of registery --- pkg/drivers/kic/kic.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/drivers/kic/kic.go b/pkg/drivers/kic/kic.go index b75c4138d43a..22929d455cdb 100644 --- a/pkg/drivers/kic/kic.go +++ b/pkg/drivers/kic/kic.go @@ -93,8 +93,14 @@ func (d *Driver) Create() error { ListenAddress: oci.DefaultBindIPV4, ContainerPort: constants.DockerDaemonPort, }, + oci.PortMapping{ + ListenAddress: oci.DefaultBindIPV4, + ContainerPort: constants.RegisteryAddonPort, + }, ) + fmt.Println("ruben") + exists, err := oci.ContainerExists(d.OCIBinary, params.Name) if err != nil { glog.Warningf("failed to check if container already exists: %v", err) @@ -203,6 +209,15 @@ func (d *Driver) GetSSHPort() (int, error) { return p, nil } +//// GetRegisteryAddonPort returns port for use with ssh +//func (d *Driver) GetRegisteryAddonPort() (int, error) { +// p, err := oci.ForwardedPort(d.OCIBinary, d.MachineName, constants.RegisteryAddonPort) +// if err != nil { +// return p, errors.Wrap(err, "get ssh host-port") +// } +// return p, nil +//} + // GetSSHUsername returns the ssh username func (d *Driver) GetSSHUsername() string { return "docker" From 428d9ee9117e01eab14963dbcc17f8335586e34e Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 10 Apr 2020 14:45:43 -0500 Subject: [PATCH 03/31] add new addon --- pkg/addons/addons.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index b39ee3f60174..977c14a571bc 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -176,6 +176,16 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri return nil } + if name == "registry" { + port, err := machine.RegisteryPort(host) + if err != nil { + errors.Wrap(err, "cant get Registry port") + } + if runtime.GOOS != "linux" { + fmt.Printf("Your OS should use this port: %s", port) + } + } + cmd, err := machine.CommandRunner(host) if err != nil { return errors.Wrap(err, "command runner") From c4ef1b3798911d3608a552478863302a6a38c5ef Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 10 Apr 2020 14:46:31 -0500 Subject: [PATCH 04/31] add return port logic --- pkg/drivers/kic/kic.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/drivers/kic/kic.go b/pkg/drivers/kic/kic.go index 22929d455cdb..c5159b2b5787 100644 --- a/pkg/drivers/kic/kic.go +++ b/pkg/drivers/kic/kic.go @@ -209,14 +209,18 @@ func (d *Driver) GetSSHPort() (int, error) { return p, nil } -//// GetRegisteryAddonPort returns port for use with ssh -//func (d *Driver) GetRegisteryAddonPort() (int, error) { -// p, err := oci.ForwardedPort(d.OCIBinary, d.MachineName, constants.RegisteryAddonPort) -// if err != nil { -// return p, errors.Wrap(err, "get ssh host-port") -// } -// return p, nil -//} +func (d *Driver) GetRegisteryHostname() (string, error) { + return oci.DefaultBindIPV4, nil +} + +// GetRegisteryAddonPort returns port for use with ssh +func (d *Driver) GetRegisteryAddonPort() (int, error) { + p, err := oci.ForwardedPort(d.OCIBinary, d.MachineName, constants.RegisteryAddonPort) + if err != nil { + return p, errors.Wrap(err, "get registery host-port") + } + return p, nil +} // GetSSHUsername returns the ssh username func (d *Driver) GetSSHUsername() string { From 79593cb757424804f00d0722f9c91e203715e8d8 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 10 Apr 2020 14:47:26 -0500 Subject: [PATCH 05/31] add addon struct --- pkg/minikube/machine/client.go | 11 +++++++++++ pkg/minikube/registry/global.go | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/pkg/minikube/machine/client.go b/pkg/minikube/machine/client.go index 49f0a901beac..374ddc62c80c 100644 --- a/pkg/minikube/machine/client.go +++ b/pkg/minikube/machine/client.go @@ -169,6 +169,17 @@ func SSHRunner(h *host.Host) (command.Runner, error) { return command.NewSSHRunner(client), nil } + +// Registery return port +func RegisteryPort(h *host.Host) (string, error) { + values, err := registry.GetRegisteryAddonPort(h.Driver) + if err != nil { + errors.Wrap(err, "failed to get Registery hostname and port") + } + return string(values.Port), nil +} + + // Create creates the host func (api *LocalClient) Create(h *host.Host) error { glog.Infof("LocalClient.Create starting") diff --git a/pkg/minikube/registry/global.go b/pkg/minikube/registry/global.go index 3f608ef4712c..0c349c1b254e 100644 --- a/pkg/minikube/registry/global.go +++ b/pkg/minikube/registry/global.go @@ -18,6 +18,8 @@ package registry import ( "fmt" + "github.com/docker/machine/libmachine/drivers" + "github.com/pkg/errors" "os" "sort" @@ -72,6 +74,11 @@ type DriverState struct { Rejection string } +type registeryClient struct { + IP string + Port int +} + func (d DriverState) String() string { if d.Priority == Experimental { return fmt.Sprintf("%s (experimental)", d.Name) @@ -79,6 +86,22 @@ func (d DriverState) String() string { return d.Name } +func GetRegisteryAddonPort(d drivers.Driver) (*registeryClient, error) { + + ip, err := d.GetRegisteryHostname() + if err != nil { + return nil, errors.Wrap(err, "Error getting ssh host name for driver") + } + port, err := d.GetRegisteryAddonPort() + if err != nil { + return nil, errors.Wrap(err, "Error getting ssh port for driver") + } + return ®isteryClient{ + IP: ip, + Port: port, + }, nil +} + // List lists drivers in global registry func List() []DriverDef { return globalRegistry.List() From 3bd143037bcdfc3f0fc5f9a6f47bac2b1564dcd2 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 10 Apr 2020 18:49:54 -0500 Subject: [PATCH 06/31] change output message --- pkg/addons/addons.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index 977c14a571bc..ede4fd08c685 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -177,12 +177,12 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri } if name == "registry" { - port, err := machine.RegisteryPort(host) + port, err := machine.RegistryPort(cc) if err != nil { - errors.Wrap(err, "cant get Registry port") + errors.Wrap(err, "Can't get Registry port") } if runtime.GOOS != "linux" { - fmt.Printf("Your OS should use this port: %s", port) + out.T(out.Notice, `This is the port you should use for the registry addon "{{.port}}"`, out.V{"port": port}) } } From 201a2bbc6265ed34d1e148e8c6ac9479d3057ded Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 10 Apr 2020 18:50:57 -0500 Subject: [PATCH 07/31] remove driver and use clusterConfig --- pkg/drivers/kic/kic.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/drivers/kic/kic.go b/pkg/drivers/kic/kic.go index c5159b2b5787..509267f9980d 100644 --- a/pkg/drivers/kic/kic.go +++ b/pkg/drivers/kic/kic.go @@ -18,6 +18,7 @@ package kic import ( "fmt" + "k8s.io/minikube/pkg/minikube/config" "net" "os/exec" "strconv" @@ -95,12 +96,10 @@ func (d *Driver) Create() error { }, oci.PortMapping{ ListenAddress: oci.DefaultBindIPV4, - ContainerPort: constants.RegisteryAddonPort, + ContainerPort: constants.RegistryAddonPort, }, ) - fmt.Println("ruben") - exists, err := oci.ContainerExists(d.OCIBinary, params.Name) if err != nil { glog.Warningf("failed to check if container already exists: %v", err) @@ -209,15 +208,11 @@ func (d *Driver) GetSSHPort() (int, error) { return p, nil } -func (d *Driver) GetRegisteryHostname() (string, error) { - return oci.DefaultBindIPV4, nil -} - -// GetRegisteryAddonPort returns port for use with ssh -func (d *Driver) GetRegisteryAddonPort() (int, error) { - p, err := oci.ForwardedPort(d.OCIBinary, d.MachineName, constants.RegisteryAddonPort) +// GetRegistryAddonPort returns port for use with registry +func GetRegistryAddonPort(cc *config.ClusterConfig) (int, error) { + p, err := oci.ForwardedPort(cc.Driver, cc.Name, constants.RegistryAddonPort) if err != nil { - return p, errors.Wrap(err, "get registery host-port") + return p, errors.Wrap(err, "get registry port") } return p, nil } From f48d2ca1923378139bf469bed47821e30f35f0ab Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 10 Apr 2020 18:51:28 -0500 Subject: [PATCH 08/31] change constant name --- pkg/minikube/constants/constants.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index 255ee134d517..5329b9f59f2e 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -40,8 +40,8 @@ const ( APIServerPort = 8443 // SSHPort is the SSH serviceport on the node vm and container SSHPort = 22 - // RegisteryAddonPort os the default registery addon port - RegisteryAddonPort = 5000 + // RegistryAddonPort os the default registry addon port + RegistryAddonPort = 5000 // APIServerName is the default API server name APIServerName = "minikubeCA" From 6f3418315969a0c2b98d2ea44128d874ba41491b Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 10 Apr 2020 18:52:16 -0500 Subject: [PATCH 09/31] add KIC validation --- pkg/minikube/machine/client.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/minikube/machine/client.go b/pkg/minikube/machine/client.go index 374ddc62c80c..345ed154ba15 100644 --- a/pkg/minikube/machine/client.go +++ b/pkg/minikube/machine/client.go @@ -20,6 +20,9 @@ import ( "crypto/tls" "encoding/json" "fmt" + "k8s.io/minikube/pkg/drivers/kic" + "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/constants" "net" "os" "path/filepath" @@ -170,13 +173,16 @@ func SSHRunner(h *host.Host) (command.Runner, error) { } -// Registery return port -func RegisteryPort(h *host.Host) (string, error) { - values, err := registry.GetRegisteryAddonPort(h.Driver) - if err != nil { - errors.Wrap(err, "failed to get Registery hostname and port") +// RegistryPort return registry addon port +func RegistryPort(cc *config.ClusterConfig) (int, error) { + if driver.IsKIC(cc.Driver) { + registryPort, err := kic.GetRegistryAddonPort(cc) + if err != nil { + errors.Wrap(err, "failed to get Registry port") + } + return registryPort, nil } - return string(values.Port), nil + return constants.RegistryAddonPort, nil } From 01e0237404dd91a54d35746efd88d671bd1e26b8 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 10 Apr 2020 18:52:59 -0500 Subject: [PATCH 10/31] remove test code --- pkg/minikube/registry/global.go | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/pkg/minikube/registry/global.go b/pkg/minikube/registry/global.go index 0c349c1b254e..3f608ef4712c 100644 --- a/pkg/minikube/registry/global.go +++ b/pkg/minikube/registry/global.go @@ -18,8 +18,6 @@ package registry import ( "fmt" - "github.com/docker/machine/libmachine/drivers" - "github.com/pkg/errors" "os" "sort" @@ -74,11 +72,6 @@ type DriverState struct { Rejection string } -type registeryClient struct { - IP string - Port int -} - func (d DriverState) String() string { if d.Priority == Experimental { return fmt.Sprintf("%s (experimental)", d.Name) @@ -86,22 +79,6 @@ func (d DriverState) String() string { return d.Name } -func GetRegisteryAddonPort(d drivers.Driver) (*registeryClient, error) { - - ip, err := d.GetRegisteryHostname() - if err != nil { - return nil, errors.Wrap(err, "Error getting ssh host name for driver") - } - port, err := d.GetRegisteryAddonPort() - if err != nil { - return nil, errors.Wrap(err, "Error getting ssh port for driver") - } - return ®isteryClient{ - IP: ip, - Port: port, - }, nil -} - // List lists drivers in global registry func List() []DriverDef { return globalRegistry.List() From e63627252d364bccd2e888f6d6f8d3167e1b7f1f Mon Sep 17 00:00:00 2001 From: Ruben Baez Date: Fri, 10 Apr 2020 20:09:12 -0500 Subject: [PATCH 11/31] Update docker.md --- site/content/en/docs/drivers/docker.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/site/content/en/docs/drivers/docker.md b/site/content/en/docs/drivers/docker.md index 248428753d19..65e1db23037d 100644 --- a/site/content/en/docs/drivers/docker.md +++ b/site/content/en/docs/drivers/docker.md @@ -19,8 +19,6 @@ The Docker driver allows you to install Kubernetes into an existing Docker insta ## Known Issues -- On macOS, containers might get hung and require a restart of Docker for Desktop. See [docker/for-mac#1835](https://github.com/docker/for-mac/issues/1835) - - The `ingress`, `ingress-dns` and `registry` addons are currently only supported on Linux. See [#7332](https://github.com/kubernetes/minikube/issues/7332) and [#7535](https://github.com/kubernetes/minikube/issues/7535) - On WSL2 (experimental - see [#5392](https://github.com/kubernetes/minikube/issues/5392)), you may need to run: @@ -33,5 +31,4 @@ The Docker driver allows you to install Kubernetes into an existing Docker insta ## Troubleshooting -- On macOS or Windows, you may need to restart Docker for Desktop if a command gets hung - Run `--alsologtostderr -v=1` for extra debugging information From a9e87bd8a39ea1be76c64df457cde654b44a6441 Mon Sep 17 00:00:00 2001 From: Ruben Baez Date: Fri, 10 Apr 2020 20:14:32 -0500 Subject: [PATCH 12/31] Update docker.md --- site/content/en/docs/drivers/docker.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/site/content/en/docs/drivers/docker.md b/site/content/en/docs/drivers/docker.md index 248428753d19..ccd7b6017ad1 100644 --- a/site/content/en/docs/drivers/docker.md +++ b/site/content/en/docs/drivers/docker.md @@ -27,9 +27,6 @@ The Docker driver allows you to install Kubernetes into an existing Docker insta `sudo mkdir /sys/fs/cgroup/systemd && sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd`. -- Addon 'registry' for mac and windows is not supported yet and it is [a work in progress](https://github.com/kubernetes/minikube/issues/7535). - - ## Troubleshooting From 4f86c3e5c8cc6b4a2c6486299b59421ed06b525c Mon Sep 17 00:00:00 2001 From: Alonyb Date: Sat, 11 Apr 2020 00:56:34 -0500 Subject: [PATCH 13/31] some adjustments --- pkg/addons/addons.go | 14 ++++++++------ pkg/minikube/machine/client.go | 17 ----------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index ede4fd08c685..d600c1f01e6e 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -18,6 +18,7 @@ package addons import ( "fmt" + "k8s.io/minikube/pkg/drivers/kic" "path" "runtime" "sort" @@ -177,12 +178,13 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri } if name == "registry" { - port, err := machine.RegistryPort(cc) - if err != nil { - errors.Wrap(err, "Can't get Registry port") - } - if runtime.GOOS != "linux" { - out.T(out.Notice, `This is the port you should use for the registry addon "{{.port}}"`, out.V{"port": port}) + if driver.IsKIC(cc.Driver) && runtime.GOOS != "linux" { + port, err := kic.GetRegistryAddonPort(cc) + if err != nil { + errors.Wrap(err, "registry port") + } + out.T(out.Notice, `Registry addon on with {{.driver}} uses {{.port}} please use that. +For more information see: https://minikube.sigs.k8s.io/docs/drivers/docker/#install-docker to documentation`, out.V{"driver":cc.Driver, "port": port}) } } diff --git a/pkg/minikube/machine/client.go b/pkg/minikube/machine/client.go index 345ed154ba15..49f0a901beac 100644 --- a/pkg/minikube/machine/client.go +++ b/pkg/minikube/machine/client.go @@ -20,9 +20,6 @@ import ( "crypto/tls" "encoding/json" "fmt" - "k8s.io/minikube/pkg/drivers/kic" - "k8s.io/minikube/pkg/minikube/config" - "k8s.io/minikube/pkg/minikube/constants" "net" "os" "path/filepath" @@ -172,20 +169,6 @@ func SSHRunner(h *host.Host) (command.Runner, error) { return command.NewSSHRunner(client), nil } - -// RegistryPort return registry addon port -func RegistryPort(cc *config.ClusterConfig) (int, error) { - if driver.IsKIC(cc.Driver) { - registryPort, err := kic.GetRegistryAddonPort(cc) - if err != nil { - errors.Wrap(err, "failed to get Registry port") - } - return registryPort, nil - } - return constants.RegistryAddonPort, nil -} - - // Create creates the host func (api *LocalClient) Create(h *host.Host) error { glog.Infof("LocalClient.Create starting") From bd5fd8160deceac4b6ed88f04b1400fe56eab484 Mon Sep 17 00:00:00 2001 From: Ruben Baez Date: Sat, 11 Apr 2020 01:32:56 -0500 Subject: [PATCH 14/31] Update docker.md --- site/content/en/docs/drivers/docker.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site/content/en/docs/drivers/docker.md b/site/content/en/docs/drivers/docker.md index 4a2a000633d0..b26f6a879fa4 100644 --- a/site/content/en/docs/drivers/docker.md +++ b/site/content/en/docs/drivers/docker.md @@ -19,6 +19,8 @@ The Docker driver allows you to install Kubernetes into an existing Docker insta ## Known Issues +- On macOS, containers might get hung and require a restart of Docker for Desktop. See [docker/for-mac#1835](https://github.com/docker/for-mac/issues/1835) + - The `ingress`, `ingress-dns` and `registry` addons are currently only supported on Linux. See [#7332](https://github.com/kubernetes/minikube/issues/7332) and [#7535](https://github.com/kubernetes/minikube/issues/7535) - On WSL2 (experimental - see [#5392](https://github.com/kubernetes/minikube/issues/5392)), you may need to run: @@ -28,4 +30,6 @@ The Docker driver allows you to install Kubernetes into an existing Docker insta ## Troubleshooting +- On macOS or Windows, you may need to restart Docker for Desktop if a command gets hung + - Run `--alsologtostderr -v=1` for extra debugging information From 2452471e163eccff54c8b1bffe2074355567b407 Mon Sep 17 00:00:00 2001 From: Ruben Baez Date: Sat, 11 Apr 2020 02:34:51 -0500 Subject: [PATCH 15/31] Create registry_addon_mac_windows.inc --- .../includes/registry_addon_mac_windows.inc | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc diff --git a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc new file mode 100644 index 000000000000..c838c44e6664 --- /dev/null +++ b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc @@ -0,0 +1,28 @@ +## Requirements + +* Run on Mac OS or Windows +* Registry addon enabled +* Run Minikube on KIC driver. + +## Start Minikube enabling registry addon + +Open a shell console, and run the following command: + +```bash +minikube start --addons=registry --vm-driver={{docker | podman}} +``` + +## Usage Registry + +Build docker image and tag it appropriately: + +```shell +docker build --tag $(minikube ip):5000/test-img . +``` +Push docker image to minikube registry: + +```shell +docker push $(minikube ip):5000/test-img +``` + +* For more information, documentation ([Pushing to an in-cluster using Registry addon](https://minikube.sigs.k8s.io/docs/handbook/pushing/#4-pushing-to-an-in-cluster-using-registry-addon)) From a34ada808a7a5466a653f891a25a6697a5080f6c Mon Sep 17 00:00:00 2001 From: Ruben Baez Date: Sat, 11 Apr 2020 02:49:03 -0500 Subject: [PATCH 16/31] add regisrtry_addon_mac_windows_usage.inc --- site/content/en/docs/drivers/docker.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/site/content/en/docs/drivers/docker.md b/site/content/en/docs/drivers/docker.md index b26f6a879fa4..d2cc12b44458 100644 --- a/site/content/en/docs/drivers/docker.md +++ b/site/content/en/docs/drivers/docker.md @@ -11,6 +11,9 @@ The Docker driver allows you to install Kubernetes into an existing Docker insta {{% readfile file="/docs/drivers/includes/docker_usage.inc" %}} +{{% readfile file="/docs/drivers/includes/regisrtry_addon_mac_windows_usage.inc" %}} + + ## Special features - Cross platform (linux, macOS, Windows) From 338e61bd21e25e911bd6621083ec6c478c6a14a2 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Sat, 11 Apr 2020 13:31:51 -0500 Subject: [PATCH 17/31] change output message icon --- pkg/addons/addons.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index d600c1f01e6e..9a86e1a0158f 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -183,7 +183,7 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri if err != nil { errors.Wrap(err, "registry port") } - out.T(out.Notice, `Registry addon on with {{.driver}} uses {{.port}} please use that. + out.T(out.Documentation, `Registry addon on with {{.driver}} uses {{.port}} please use that. For more information see: https://minikube.sigs.k8s.io/docs/drivers/docker/#install-docker to documentation`, out.V{"driver":cc.Driver, "port": port}) } } From 62904e5dccfeaf75213bbe58a59cbb58bd75fe54 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Wed, 15 Apr 2020 09:30:10 -0500 Subject: [PATCH 18/31] fix lint --- pkg/addons/addons.go | 7 ++++--- pkg/drivers/kic/kic.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index 9a86e1a0158f..b147af4580f9 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -18,7 +18,6 @@ package addons import ( "fmt" - "k8s.io/minikube/pkg/drivers/kic" "path" "runtime" "sort" @@ -29,6 +28,8 @@ import ( "github.com/golang/glog" "github.com/pkg/errors" + + "k8s.io/minikube/pkg/drivers/kic" "k8s.io/minikube/pkg/minikube/assets" "k8s.io/minikube/pkg/minikube/command" "k8s.io/minikube/pkg/minikube/config" @@ -181,10 +182,10 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri if driver.IsKIC(cc.Driver) && runtime.GOOS != "linux" { port, err := kic.GetRegistryAddonPort(cc) if err != nil { - errors.Wrap(err, "registry port") + return errors.Wrap(err, "registry port") } out.T(out.Documentation, `Registry addon on with {{.driver}} uses {{.port}} please use that. -For more information see: https://minikube.sigs.k8s.io/docs/drivers/docker/#install-docker to documentation`, out.V{"driver":cc.Driver, "port": port}) +For more information see: https://minikube.sigs.k8s.io/docs/drivers/docker/#install-docker to documentation`, out.V{"driver": cc.Driver, "port": port}) } } diff --git a/pkg/drivers/kic/kic.go b/pkg/drivers/kic/kic.go index c0b161b8c111..fda3733ed144 100644 --- a/pkg/drivers/kic/kic.go +++ b/pkg/drivers/kic/kic.go @@ -18,7 +18,6 @@ package kic import ( "fmt" - "k8s.io/minikube/pkg/minikube/config" "net" "os/exec" "strconv" @@ -36,6 +35,7 @@ import ( "k8s.io/minikube/pkg/drivers/kic/oci" "k8s.io/minikube/pkg/minikube/assets" "k8s.io/minikube/pkg/minikube/command" + "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/cruntime" "k8s.io/minikube/pkg/minikube/download" From db8af9d7b34727a3e4824ddeb814b531be5a1cc3 Mon Sep 17 00:00:00 2001 From: Ruben Baez Date: Thu, 16 Apr 2020 08:40:40 -0500 Subject: [PATCH 19/31] Update registry_addon_mac_windows.inc --- .../includes/registry_addon_mac_windows.inc | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc index c838c44e6664..d3a887870102 100644 --- a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc +++ b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc @@ -1,8 +1,26 @@ +--- + +## Table for different drivers. +The registry addon works in all OS, to use it depends on the driver you built your cluster with, If you are using container system (Docker, Podman) in Mac or Windows OS it has some limitation, is this case you will have to use the forwarded port for 5000. + +Here is a table to help you with registry addon: + +| Drivers | Supported Status | Drivers to port forward | Ports | +|--- |--- |--- |--- |--- | +| [Linux drivers](/docs/drivers) | works fine | | 5000 | +| [Mac drivers](/docs/drivers) | works fine | [Docker](/docs/drivers/docker/) | random | +| [Windows drivers](/docs/drivers) | works fine | [Docker](docs/drivers/docker/) | random | + + +* note1 : The default port for linux drivers is 5000. +* note2 : Drivers for Docker driver is random like (87362). + +--- + ## Requirements -* Run on Mac OS or Windows * Registry addon enabled -* Run Minikube on KIC driver. +* Run Minikube on KIC driver (see table). ## Start Minikube enabling registry addon @@ -12,6 +30,14 @@ Open a shell console, and run the following command: minikube start --addons=registry --vm-driver={{docker | podman}} ``` +## Before usage Registry + +Make sure the port you have to use, you can see it as a result of the previous command, or seeing the port forward running(in case of docker driver on Mac or Windows): + +```shell +docker ps +``` + ## Usage Registry Build docker image and tag it appropriately: From 373616b1884144e5eed718f1001f138fbea4748d Mon Sep 17 00:00:00 2001 From: Ruben Baez Date: Thu, 16 Apr 2020 09:31:13 -0500 Subject: [PATCH 20/31] Update registry_addon_mac_windows.inc --- .../en/docs/drivers/includes/registry_addon_mac_windows.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc index d3a887870102..d35bfd26e29d 100644 --- a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc +++ b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc @@ -51,4 +51,6 @@ Push docker image to minikube registry: docker push $(minikube ip):5000/test-img ``` +After the image is pushed, refer to it by `localhost:5000/{name}` in kubectl specs. + * For more information, documentation ([Pushing to an in-cluster using Registry addon](https://minikube.sigs.k8s.io/docs/handbook/pushing/#4-pushing-to-an-in-cluster-using-registry-addon)) From 8c00b17da56cd4b65ea1f3fad44c3e773333d870 Mon Sep 17 00:00:00 2001 From: Ruben Baez Date: Thu, 16 Apr 2020 09:37:46 -0500 Subject: [PATCH 21/31] Update registry.md --- site/content/en/docs/handbook/registry.md | 66 +---------------------- 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/site/content/en/docs/handbook/registry.md b/site/content/en/docs/handbook/registry.md index 5d6d8d83859f..f94eb844c825 100644 --- a/site/content/en/docs/handbook/registry.md +++ b/site/content/en/docs/handbook/registry.md @@ -44,67 +44,5 @@ One nifty hack is to allow the kubelet running in minikube to talk to registries with TLS certificates. Because the default service cluster IP is known to be available at 10.0.0.1, users can pull images from registries deployed inside the cluster by creating the cluster with `minikube start --insecure-registry "10.0.0.0/24"`. -### docker on macOS - -Quick guide for configuring minikube and docker on macOS, enabling docker to push images to minikube's registry. - -The first step is to enable the registry addon: - -``` -minikube addons enable registry -``` - -When enabled, the registry addon exposes its port 5000 on the minikube's virtual machine. - -In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. We can (ab)use docker's network configuration to instantiate a container on the docker's host, and run socat there: - -``` -docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:$(minikube ip):5000" -``` - -Once socat is running it's possible to push images to the minikube registry: - -``` -docker tag my/image localhost:5000/myimage -docker push localhost:5000/myimage -``` - -After the image is pushed, refer to it by `localhost:5000/{name}` in kubectl specs. - -### Docker on Windows - -Quick guide for configuring minikube and docker on Windows, enabling docker to push images to minikube's registry. - -The first step is to enable the registry addon: - -``` -minikube addons enable registry -``` - -When enabled, the registry addon exposes its port 5000 on the minikube's virtual machine. - -In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. Unfortunately, the docker vm cannot directly see the IP address of the minikube vm. To fix this, you will have to add one more level of redirection. - -Use kubectl port-forward to map your local workstation to the minikube vm -``` -kubectl port-forward --namespace kube-system 5000:5000 -``` - -On your local machine you should now be able to reach the minikube registry by using `curl http://localhost:5000/v2/_catalog` - -From this point we can (ab)use docker's network configuration to instantiate a container on the docker's host, and run socat there to redirect traffic going to the docker vm's port 5000 to port 5000 on your host workstation. - -``` -docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" -``` - -Once socat is running it's possible to push images to the minikube registry from your local workstation: - -``` -docker tag my/image localhost:5000/myimage -docker push localhost:5000/myimage -``` - -After the image is pushed, refer to it by `localhost:5000/{name}` in kubectl specs. - -## \ No newline at end of file +--- +{{% readfile file="/docs/drivers/includes/regisrtry_addon_mac_windows_usage.inc" %}} From 59e9c834b9211833e46588ff08905a222389c2bc Mon Sep 17 00:00:00 2001 From: Alonyb Date: Thu, 16 Apr 2020 17:58:36 -0500 Subject: [PATCH 22/31] fix registry addon template --- site/content/en/docs/drivers/docker.md | 3 --- site/content/en/docs/handbook/registry.md | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/site/content/en/docs/drivers/docker.md b/site/content/en/docs/drivers/docker.md index d2cc12b44458..b26f6a879fa4 100644 --- a/site/content/en/docs/drivers/docker.md +++ b/site/content/en/docs/drivers/docker.md @@ -11,9 +11,6 @@ The Docker driver allows you to install Kubernetes into an existing Docker insta {{% readfile file="/docs/drivers/includes/docker_usage.inc" %}} -{{% readfile file="/docs/drivers/includes/regisrtry_addon_mac_windows_usage.inc" %}} - - ## Special features - Cross platform (linux, macOS, Windows) diff --git a/site/content/en/docs/handbook/registry.md b/site/content/en/docs/handbook/registry.md index f94eb844c825..41f90d15937d 100644 --- a/site/content/en/docs/handbook/registry.md +++ b/site/content/en/docs/handbook/registry.md @@ -44,5 +44,4 @@ One nifty hack is to allow the kubelet running in minikube to talk to registries with TLS certificates. Because the default service cluster IP is known to be available at 10.0.0.1, users can pull images from registries deployed inside the cluster by creating the cluster with `minikube start --insecure-registry "10.0.0.0/24"`. ---- -{{% readfile file="/docs/drivers/includes/regisrtry_addon_mac_windows_usage.inc" %}} +{{% readfile file="/docs/drivers/includes/registry_addon_mac_windows.inc" %}} From d573b6c5d9689b6a5aa6f616eb6c7df238944d15 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Thu, 16 Apr 2020 19:26:55 -0500 Subject: [PATCH 23/31] add docker inspect command --- .../includes/registry_addon_mac_windows.inc | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc index d35bfd26e29d..4cf16a088cbe 100644 --- a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc +++ b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc @@ -5,15 +5,15 @@ The registry addon works in all OS, to use it depends on the driver you built yo Here is a table to help you with registry addon: -| Drivers | Supported Status | Drivers to port forward | Ports | +| Drivers | Ports | |--- |--- |--- |--- |--- | -| [Linux drivers](/docs/drivers) | works fine | | 5000 | -| [Mac drivers](/docs/drivers) | works fine | [Docker](/docs/drivers/docker/) | random | -| [Windows drivers](/docs/drivers) | works fine | [Docker](docs/drivers/docker/) | random | +| [Docker driver on Linux](/docs/drivers) | 5000 | +| [Docker driver on Mac and windows](/docs/drivers) | Random | +| [All other drivers](/docs/drivers) | Random | * note1 : The default port for linux drivers is 5000. -* note2 : Drivers for Docker driver is random like (87362). +* note2 : Drivers for Docker driver is random. --- @@ -30,27 +30,19 @@ Open a shell console, and run the following command: minikube start --addons=registry --vm-driver={{docker | podman}} ``` -## Before usage Registry - -Make sure the port you have to use, you can see it as a result of the previous command, or seeing the port forward running(in case of docker driver on Mac or Windows): - -```shell -docker ps -``` - ## Usage Registry Build docker image and tag it appropriately: ```shell -docker build --tag $(minikube ip):5000/test-img . +docker build --tag $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' )/test-img . ``` Push docker image to minikube registry: ```shell -docker push $(minikube ip):5000/test-img +docker push $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' /test-img ``` After the image is pushed, refer to it by `localhost:5000/{name}` in kubectl specs. -* For more information, documentation ([Pushing to an in-cluster using Registry addon](https://minikube.sigs.k8s.io/docs/handbook/pushing/#4-pushing-to-an-in-cluster-using-registry-addon)) +* For more information, documentation ([Pushing to an in-cluster using Registry addon](https://minikube.sigs.k8s.io/docs/handbook/pushing/#4-pushing-to-an-in-cluster-using-registry-addon)) \ No newline at end of file From bfa45ef79ae4b9e762dceaa581b16f0a7151fadd Mon Sep 17 00:00:00 2001 From: Alonyb Date: Thu, 16 Apr 2020 19:49:26 -0500 Subject: [PATCH 24/31] delete unnecesary func --- pkg/addons/addons.go | 11 ++++++----- pkg/drivers/kic/kic.go | 10 ---------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index b147af4580f9..7ed9c904b020 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -29,10 +29,11 @@ import ( "github.com/golang/glog" "github.com/pkg/errors" - "k8s.io/minikube/pkg/drivers/kic" + "k8s.io/minikube/pkg/drivers/kic/oci" "k8s.io/minikube/pkg/minikube/assets" "k8s.io/minikube/pkg/minikube/command" "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/driver" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/machine" @@ -179,13 +180,13 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri } if name == "registry" { - if driver.IsKIC(cc.Driver) && runtime.GOOS != "linux" { - port, err := kic.GetRegistryAddonPort(cc) + if driver.NeedsPortForward(cc.Driver) { + port, err := oci.ForwardedPort(cc.Driver, cc.Name, constants.RegistryAddonPort) if err != nil { return errors.Wrap(err, "registry port") } - out.T(out.Documentation, `Registry addon on with {{.driver}} uses {{.port}} please use that. -For more information see: https://minikube.sigs.k8s.io/docs/drivers/docker/#install-docker to documentation`, out.V{"driver": cc.Driver, "port": port}) + out.T(out.Tip, `Registry addon on with {{.driver}} uses {{.port}} please use that instead of default 5000`, out.V{"driver": cc.Driver, "port": port}) + out.T(out.Documentation, `For more information see: https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}`, out.V{"driver": cc.Driver}) } } diff --git a/pkg/drivers/kic/kic.go b/pkg/drivers/kic/kic.go index fda3733ed144..235954787944 100644 --- a/pkg/drivers/kic/kic.go +++ b/pkg/drivers/kic/kic.go @@ -35,7 +35,6 @@ import ( "k8s.io/minikube/pkg/drivers/kic/oci" "k8s.io/minikube/pkg/minikube/assets" "k8s.io/minikube/pkg/minikube/command" - "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/cruntime" "k8s.io/minikube/pkg/minikube/download" @@ -208,15 +207,6 @@ func (d *Driver) GetSSHPort() (int, error) { return p, nil } -// GetRegistryAddonPort returns port for use with registry -func GetRegistryAddonPort(cc *config.ClusterConfig) (int, error) { - p, err := oci.ForwardedPort(cc.Driver, cc.Name, constants.RegistryAddonPort) - if err != nil { - return p, errors.Wrap(err, "get registry port") - } - return p, nil -} - // GetSSHUsername returns the ssh username func (d *Driver) GetSSHUsername() string { return "docker" From 5ec186229059e6f45028e4a6efcf1b3b556290a5 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Thu, 16 Apr 2020 20:29:09 -0500 Subject: [PATCH 25/31] delete links --- .../docs/drivers/includes/registry_addon_mac_windows.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc index 4cf16a088cbe..33fda2224fff 100644 --- a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc +++ b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc @@ -5,11 +5,11 @@ The registry addon works in all OS, to use it depends on the driver you built yo Here is a table to help you with registry addon: -| Drivers | Ports | +| Drivers | Port | |--- |--- |--- |--- |--- | -| [Docker driver on Linux](/docs/drivers) | 5000 | -| [Docker driver on Mac and windows](/docs/drivers) | Random | -| [All other drivers](/docs/drivers) | Random | +| Docker driver on Linux | 5000 | +| Docker driver on Mac and windows | Random | +| All other drivers | 5000 | * note1 : The default port for linux drivers is 5000. From 2f940d84a9799e8945ae899437f427f77e6461f3 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Thu, 16 Apr 2020 20:47:48 -0500 Subject: [PATCH 26/31] update registry_addon_mac_windows.inc --- .../includes/registry_addon_mac_windows.inc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc index 33fda2224fff..7c21b73afea9 100644 --- a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc +++ b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc @@ -30,7 +30,20 @@ Open a shell console, and run the following command: minikube start --addons=registry --vm-driver={{docker | podman}} ``` -## Usage Registry +## 1. Usage Registry for drivers that dont need port forward + +Build docker image and tag it appropriately: + +```shell +docker build --tag $(minikube ip):5000 )/test-img . +``` +Push docker image to minikube registry: + +```shell +docker push $(minikube ip):5000 /test-img +``` + +## 2. Use Registry for docker on mac and windows Build docker image and tag it appropriately: From 40e87af21d86d34137b79e0193ef7d37477705a1 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Thu, 16 Apr 2020 20:56:52 -0500 Subject: [PATCH 27/31] fix docker commands --- .../en/docs/drivers/includes/registry_addon_mac_windows.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc index 7c21b73afea9..4bb71d51c379 100644 --- a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc +++ b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc @@ -35,12 +35,12 @@ minikube start --addons=registry --vm-driver={{docker | podman}} Build docker image and tag it appropriately: ```shell -docker build --tag $(minikube ip):5000 )/test-img . +docker build --tag $(minikube ip):5000/test-img . ``` Push docker image to minikube registry: ```shell -docker push $(minikube ip):5000 /test-img +docker push $(minikube ip):5000/test-img ``` ## 2. Use Registry for docker on mac and windows From 6bde0e0f5d5d06ed3f4ee10b949256cef3e9fbe4 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 17 Apr 2020 14:02:52 -0500 Subject: [PATCH 28/31] change upper case & add new step --- .../includes/registry_addon_mac_windows.inc | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc index 4bb71d51c379..c1afaa8e183e 100644 --- a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc +++ b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc @@ -20,9 +20,9 @@ Here is a table to help you with registry addon: ## Requirements * Registry addon enabled -* Run Minikube on KIC driver (see table). +* Run minikube on KIC driver (see table). -## Start Minikube enabling registry addon +## Start minikube enabling registry addon Open a shell console, and run the following command: @@ -30,6 +30,7 @@ Open a shell console, and run the following command: minikube start --addons=registry --vm-driver={{docker | podman}} ``` +--- ## 1. Usage Registry for drivers that dont need port forward Build docker image and tag it appropriately: @@ -43,14 +44,39 @@ Push docker image to minikube registry: docker push $(minikube ip):5000/test-img ``` +--- ## 2. Use Registry for docker on mac and windows Build docker image and tag it appropriately: +#### Accept pushed images on Mac + +In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. We can (ab)use docker’s network configuration to instantiate a container on the docker’s host, and run socat there: + ```shell -docker build --tag $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' )/test-img . +docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:$(minikube ip):5000" ``` -Push docker image to minikube registry: + +#### Accept pushing images on Windows + +In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. Unfortunately, the docker vm cannot directly see the IP address of the minikube vm. To fix this, you will have to add one more level of redirection. + +Use kubectl port-forward to map your local workstation to the minikube vm + +```shell +kubectl port-forward --namespace kube-system 5000:5000 +``` + +On your local machine you should now be able to reach the minikube registry by using curl `http://localhost:5000/v2/_catalog` + +From this point we can (ab)use docker’s network configuration to instantiate a container on the docker’s host, and run socat there to redirect traffic going to the docker vm’s port 5000 to port 5000 on your host workstation. + +```shell +docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" +``` + + +#### Push docker image to minikube registry: ```shell docker push $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' /test-img From cef7a6fb84181f14408535fcb90235abc7575249 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 17 Apr 2020 18:39:33 -0500 Subject: [PATCH 29/31] fix documentation --- .../includes/registry_addon_mac_windows.inc | 61 ++++++++++++------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc index c1afaa8e183e..02a8aee772d3 100644 --- a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc +++ b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc @@ -11,75 +11,90 @@ Here is a table to help you with registry addon: | Docker driver on Mac and windows | Random | | All other drivers | 5000 | - -* note1 : The default port for linux drivers is 5000. -* note2 : Drivers for Docker driver is random. - --- ## Requirements * Registry addon enabled -* Run minikube on KIC driver (see table). ## Start minikube enabling registry addon Open a shell console, and run the following command: ```bash -minikube start --addons=registry --vm-driver={{docker | podman}} +minikube start --addons=registry ``` --- -## 1. Usage Registry for drivers that dont need port forward +### How to connec to registry on VM drivers on windows Build docker image and tag it appropriately: ```shell -docker build --tag $(minikube ip):5000/test-img . +docker build --tag $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}'/test-img . ``` -Push docker image to minikube registry: + +In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. Unfortunately, the docker vm cannot directly see the IP address of the minikube vm. To fix this, you will have to add one more level of redirection. + +Use kubectl port-forward to map your local workstation to the minikube vm + +```shell +kubectl port-forward --namespace kube-system 5000:5000 +``` + +On your local machine you should now be able to reach the minikube registry by using curl `http://localhost:5000/v2/_catalog` + +From this point we can (ab)use docker’s network configuration to instantiate a container on the docker’s host, and run socat there to redirect traffic going to the docker vm’s port 5000 to port 5000 on your host workstation. + +```shell +docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" +``` + + Push docker image to minikube registry: ```shell -docker push $(minikube ip):5000/test-img +docker push $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' /test-img ``` --- -## 2. Use Registry for docker on mac and windows +### How to connect to regsitery for Docker driver on Mac and Windows Build docker image and tag it appropriately: -#### Accept pushed images on Mac +```shell +docker build --tag $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}'/test-img . +``` In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. We can (ab)use docker’s network configuration to instantiate a container on the docker’s host, and run socat there: ```shell -docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:$(minikube ip):5000" +docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" ``` -#### Accept pushing images on Windows +Push docker image to minikube registry: -In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. Unfortunately, the docker vm cannot directly see the IP address of the minikube vm. To fix this, you will have to add one more level of redirection. +```shell +docker push $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' /test-img +``` -Use kubectl port-forward to map your local workstation to the minikube vm +### How to connect to resgitry for all other drivers + +Build docker image and tag it appropriately: ```shell -kubectl port-forward --namespace kube-system 5000:5000 +docker build --tag $(minikube ip):5000'/test-img . ``` -On your local machine you should now be able to reach the minikube registry by using curl `http://localhost:5000/v2/_catalog` - -From this point we can (ab)use docker’s network configuration to instantiate a container on the docker’s host, and run socat there to redirect traffic going to the docker vm’s port 5000 to port 5000 on your host workstation. +In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. We can (ab)use docker’s network configuration to instantiate a container on the docker’s host, and run socat there: ```shell docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" ``` - -#### Push docker image to minikube registry: +Push docker image to minikube registry: ```shell -docker push $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' /test-img +docker push $(minikube ip):5000 /test-img ``` After the image is pushed, refer to it by `localhost:5000/{name}` in kubectl specs. From c48b22bbd8d5ee936981063e929a025f15014772 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 17 Apr 2020 20:38:58 -0500 Subject: [PATCH 30/31] change table of pushing doc --- site/content/en/docs/handbook/pushing.md | 12 ++--- site/content/en/docs/handbook/registry.md | 65 ++++++++++++++++++++++- 2 files changed, 70 insertions(+), 7 deletions(-) diff --git a/site/content/en/docs/handbook/pushing.md b/site/content/en/docs/handbook/pushing.md index 32c58edf2fdb..7a0646c7b080 100644 --- a/site/content/en/docs/handbook/pushing.md +++ b/site/content/en/docs/handbook/pushing.md @@ -15,13 +15,13 @@ The best method to push your image to minikube depends on the container-runtime Here is a comparison table to help you choose: -| Method | Supported Runtimes | Issues | Performance | +| Method | Supported Runtimes | | Performance | |--- |--- |--- |--- |--- | -| [docker-env command](/docs/handbook/pushing/#1pushing-directly-to-the-in-cluster-docker-daemon-docker-env) | only docker | | good | -| [podman-env command](/docs/handbook/pushing/#3-pushing-directly-to-in-cluster-crio-podman-env) | only cri-o | | good | -| [cache add command](/pushing/#2-push-images-using-cache-command) | all | | ok | -| [registry addon](/docs/handbook/pushing/#4-pushing-to-an-in-cluster-using-registry-addon) | all | work in progress for [docker on mac](https://github.com/kubernetes/minikube/issues/7535) | ok | -| [minikube ssh](/docs/handbook/pushing/#5-building-images-inside-of-minikube-using-ssh) | all | | best | +| [docker-env command](/docs/handbook/pushing/#1pushing-directly-to-the-in-cluster-docker-daemon-docker-env) | only docker | good | +| [podman-env command](/docs/handbook/pushing/#3-pushing-directly-to-in-cluster-crio-podman-env) | only cri-o | good | +| [cache add command](/pushing/#2-push-images-using-cache-command) | all | ok | +| [registry addon](/docs/handbook/pushing/#4-pushing-to-an-in-cluster-using-registry-addon) | all | ok | +| [minikube ssh](/docs/handbook/pushing/#5-building-images-inside-of-minikube-using-ssh) | all | best | * note1 : the default container-runtime on minikube is 'docker'. diff --git a/site/content/en/docs/handbook/registry.md b/site/content/en/docs/handbook/registry.md index 41f90d15937d..5d6d8d83859f 100644 --- a/site/content/en/docs/handbook/registry.md +++ b/site/content/en/docs/handbook/registry.md @@ -44,4 +44,67 @@ One nifty hack is to allow the kubelet running in minikube to talk to registries with TLS certificates. Because the default service cluster IP is known to be available at 10.0.0.1, users can pull images from registries deployed inside the cluster by creating the cluster with `minikube start --insecure-registry "10.0.0.0/24"`. -{{% readfile file="/docs/drivers/includes/registry_addon_mac_windows.inc" %}} +### docker on macOS + +Quick guide for configuring minikube and docker on macOS, enabling docker to push images to minikube's registry. + +The first step is to enable the registry addon: + +``` +minikube addons enable registry +``` + +When enabled, the registry addon exposes its port 5000 on the minikube's virtual machine. + +In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. We can (ab)use docker's network configuration to instantiate a container on the docker's host, and run socat there: + +``` +docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:$(minikube ip):5000" +``` + +Once socat is running it's possible to push images to the minikube registry: + +``` +docker tag my/image localhost:5000/myimage +docker push localhost:5000/myimage +``` + +After the image is pushed, refer to it by `localhost:5000/{name}` in kubectl specs. + +### Docker on Windows + +Quick guide for configuring minikube and docker on Windows, enabling docker to push images to minikube's registry. + +The first step is to enable the registry addon: + +``` +minikube addons enable registry +``` + +When enabled, the registry addon exposes its port 5000 on the minikube's virtual machine. + +In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. Unfortunately, the docker vm cannot directly see the IP address of the minikube vm. To fix this, you will have to add one more level of redirection. + +Use kubectl port-forward to map your local workstation to the minikube vm +``` +kubectl port-forward --namespace kube-system 5000:5000 +``` + +On your local machine you should now be able to reach the minikube registry by using `curl http://localhost:5000/v2/_catalog` + +From this point we can (ab)use docker's network configuration to instantiate a container on the docker's host, and run socat there to redirect traffic going to the docker vm's port 5000 to port 5000 on your host workstation. + +``` +docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" +``` + +Once socat is running it's possible to push images to the minikube registry from your local workstation: + +``` +docker tag my/image localhost:5000/myimage +docker push localhost:5000/myimage +``` + +After the image is pushed, refer to it by `localhost:5000/{name}` in kubectl specs. + +## \ No newline at end of file From a96d8f051d538a09d0ccb04b574fa5e9dd03ccb9 Mon Sep 17 00:00:00 2001 From: Alonyb Date: Fri, 17 Apr 2020 20:42:29 -0500 Subject: [PATCH 31/31] delete windows and mac doc --- .../includes/registry_addon_mac_windows.inc | 102 ------------------ 1 file changed, 102 deletions(-) delete mode 100644 site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc diff --git a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc b/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc deleted file mode 100644 index 02a8aee772d3..000000000000 --- a/site/content/en/docs/drivers/includes/registry_addon_mac_windows.inc +++ /dev/null @@ -1,102 +0,0 @@ ---- - -## Table for different drivers. -The registry addon works in all OS, to use it depends on the driver you built your cluster with, If you are using container system (Docker, Podman) in Mac or Windows OS it has some limitation, is this case you will have to use the forwarded port for 5000. - -Here is a table to help you with registry addon: - -| Drivers | Port | -|--- |--- |--- |--- |--- | -| Docker driver on Linux | 5000 | -| Docker driver on Mac and windows | Random | -| All other drivers | 5000 | - ---- - -## Requirements - -* Registry addon enabled - -## Start minikube enabling registry addon - -Open a shell console, and run the following command: - -```bash -minikube start --addons=registry -``` - ---- -### How to connec to registry on VM drivers on windows - -Build docker image and tag it appropriately: - -```shell -docker build --tag $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}'/test-img . -``` - -In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. Unfortunately, the docker vm cannot directly see the IP address of the minikube vm. To fix this, you will have to add one more level of redirection. - -Use kubectl port-forward to map your local workstation to the minikube vm - -```shell -kubectl port-forward --namespace kube-system 5000:5000 -``` - -On your local machine you should now be able to reach the minikube registry by using curl `http://localhost:5000/v2/_catalog` - -From this point we can (ab)use docker’s network configuration to instantiate a container on the docker’s host, and run socat there to redirect traffic going to the docker vm’s port 5000 to port 5000 on your host workstation. - -```shell -docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" -``` - - Push docker image to minikube registry: - -```shell -docker push $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' /test-img -``` - ---- -### How to connect to regsitery for Docker driver on Mac and Windows - -Build docker image and tag it appropriately: - -```shell -docker build --tag $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}'/test-img . -``` - -In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. We can (ab)use docker’s network configuration to instantiate a container on the docker’s host, and run socat there: - -```shell -docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" -``` - -Push docker image to minikube registry: - -```shell -docker push $(minikube ip):$(docker inspect --format '{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}' /test-img -``` - -### How to connect to resgitry for all other drivers - -Build docker image and tag it appropriately: - -```shell -docker build --tag $(minikube ip):5000'/test-img . -``` - -In order to make docker accept pushing images to this registry, we have to redirect port 5000 on the docker virtual machine over to port 5000 on the minikube machine. We can (ab)use docker’s network configuration to instantiate a container on the docker’s host, and run socat there: - -```shell -docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000" -``` - -Push docker image to minikube registry: - -```shell -docker push $(minikube ip):5000 /test-img -``` - -After the image is pushed, refer to it by `localhost:5000/{name}` in kubectl specs. - -* For more information, documentation ([Pushing to an in-cluster using Registry addon](https://minikube.sigs.k8s.io/docs/handbook/pushing/#4-pushing-to-an-in-cluster-using-registry-addon)) \ No newline at end of file