Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add registry addon feature for docker on mac/windows #7603

Merged
merged 36 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e785012
add registery port constant
ruben-baez-seagull-com Apr 10, 2020
50c2ec4
add oci port mapping of registery
ruben-baez-seagull-com Apr 10, 2020
428d9ee
add new addon
ruben-baez-seagull-com Apr 10, 2020
c4ef1b3
add return port logic
ruben-baez-seagull-com Apr 10, 2020
79593cb
add addon struct
ruben-baez-seagull-com Apr 10, 2020
3bd1430
change output message
ruben-baez-seagull-com Apr 10, 2020
201a2bb
remove driver and use clusterConfig
ruben-baez-seagull-com Apr 10, 2020
f48d2ca
change constant name
ruben-baez-seagull-com Apr 10, 2020
6f34183
add KIC validation
ruben-baez-seagull-com Apr 10, 2020
01e0237
remove test code
ruben-baez-seagull-com Apr 10, 2020
e636272
Update docker.md
ruben-baez-seagull-com Apr 11, 2020
d372027
Merge pull request #4 from alonyb/patch-1
ruben-baez-seagull-com Apr 11, 2020
a9e87bd
Update docker.md
ruben-baez-seagull-com Apr 11, 2020
3d6b945
Merge pull request #5 from alonyb/change-documentation
ruben-baez-seagull-com Apr 11, 2020
4f86c3e
some adjustments
ruben-baez-seagull-com Apr 11, 2020
4417ac8
Merge branch 'w/add-registery-addon' of github.com:RubenBaez/minikube…
ruben-baez-seagull-com Apr 11, 2020
bd5fd81
Update docker.md
ruben-baez-seagull-com Apr 11, 2020
2452471
Create registry_addon_mac_windows.inc
ruben-baez-seagull-com Apr 11, 2020
a8e9044
Merge pull request #6 from alonyb/patch-2
ruben-baez-seagull-com Apr 11, 2020
a34ada8
add regisrtry_addon_mac_windows_usage.inc
ruben-baez-seagull-com Apr 11, 2020
338e61b
change output message icon
ruben-baez-seagull-com Apr 11, 2020
c075f49
Merge branch 'w/add-registery-addon' of github.com:RubenBaez/minikube…
ruben-baez-seagull-com Apr 11, 2020
62904e5
fix lint
ruben-baez-seagull-com Apr 15, 2020
db8af9d
Update registry_addon_mac_windows.inc
ruben-baez-seagull-com Apr 16, 2020
373616b
Update registry_addon_mac_windows.inc
ruben-baez-seagull-com Apr 16, 2020
8c00b17
Update registry.md
ruben-baez-seagull-com Apr 16, 2020
59e9c83
fix registry addon template
ruben-baez-seagull-com Apr 16, 2020
d573b6c
add docker inspect command
ruben-baez-seagull-com Apr 17, 2020
bfa45ef
delete unnecesary func
ruben-baez-seagull-com Apr 17, 2020
5ec1862
delete links
ruben-baez-seagull-com Apr 17, 2020
2f940d8
update registry_addon_mac_windows.inc
ruben-baez-seagull-com Apr 17, 2020
40e87af
fix docker commands
ruben-baez-seagull-com Apr 17, 2020
6bde0e0
change upper case & add new step
ruben-baez-seagull-com Apr 17, 2020
cef7a6f
fix documentation
ruben-baez-seagull-com Apr 17, 2020
c48b22b
change table of pushing doc
ruben-baez-seagull-com Apr 18, 2020
a96d8f0
delete windows and mac doc
ruben-baez-seagull-com Apr 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/addons/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.RegistryPort(cc)
if err != nil {
errors.Wrap(err, "Can't get Registry port")
alonyb marked this conversation as resolved.
Show resolved Hide resolved
}
if runtime.GOOS != "linux" {
alonyb marked this conversation as resolved.
Show resolved Hide resolved
out.T(out.Notice, `This is the port you should use for the registry addon "{{.port}}"`, out.V{"port": port})
alonyb marked this conversation as resolved.
Show resolved Hide resolved
}
}

cmd, err := machine.CommandRunner(host)
if err != nil {
return errors.Wrap(err, "command runner")
Expand Down
14 changes: 14 additions & 0 deletions pkg/drivers/kic/kic.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package kic

import (
"fmt"
"k8s.io/minikube/pkg/minikube/config"
"net"
"os/exec"
"strconv"
Expand Down Expand Up @@ -93,6 +94,10 @@ func (d *Driver) Create() error {
ListenAddress: oci.DefaultBindIPV4,
ContainerPort: constants.DockerDaemonPort,
},
oci.PortMapping{
ListenAddress: oci.DefaultBindIPV4,
ContainerPort: constants.RegistryAddonPort,
},
)

exists, err := oci.ContainerExists(d.OCIBinary, params.Name)
Expand Down Expand Up @@ -203,6 +208,15 @@ 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)
medyagh marked this conversation as resolved.
Show resolved Hide resolved
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"
Expand Down
2 changes: 2 additions & 0 deletions pkg/minikube/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
APIServerPort = 8443
// SSHPort is the SSH serviceport on the node vm and container
SSHPort = 22
// RegistryAddonPort os the default registry addon port
RegistryAddonPort = 5000

// APIServerName is the default API server name
APIServerName = "minikubeCA"
Expand Down
17 changes: 17 additions & 0 deletions pkg/minikube/machine/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -169,6 +172,20 @@ 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")
Expand Down