Merge pull request #1145 from aaron-prindle/etcd-access
Change etcd to be accessible within podspull/1149/head
commit
ffcccbd646
10
README.md
10
README.md
|
@ -383,7 +383,17 @@ Kubectl is now configured to use the cluster.
|
|||
# Then you can examine the profile with:
|
||||
$ go tool pprof /tmp/profile933201292/cpu.pprof
|
||||
```
|
||||
## Accessing Localkube Resources From Inside A Pod: Example etcd
|
||||
In order to access localkube resources from inside a pod, localkube's host ip address must be used. This can be obtained by running:
|
||||
```shell
|
||||
$ minikube ssh -- "sudo /usr/local/bin/localkube --host-ip"
|
||||
localkube host ip: 10.0.2.15
|
||||
```
|
||||
|
||||
You can use the host-ip:`10.0.2.15` to access localkube's resources, for example its etcd cluster. In order to access etcd from within a pod, you can run the following command inside:
|
||||
```shell
|
||||
curl -L -X PUT http://10.0.2.15:2379/v2/keys/message -d value="Hello"
|
||||
```
|
||||
|
||||
## KNOWN Issues
|
||||
* Features that require a Cloud Provider will not work in Minikube. These include:
|
||||
|
|
|
@ -61,6 +61,7 @@ func AddFlags(s *localkube.LocalkubeServer) {
|
|||
flag.IntVar(&s.APIServerInsecurePort, "apiserver-insecure-port", s.APIServerInsecurePort, "The port the apiserver will listen insecurely on")
|
||||
flag.BoolVar(&s.ShouldGenerateCerts, "generate-certs", s.ShouldGenerateCerts, "If localkube should generate it's own certificates")
|
||||
flag.BoolVar(&s.ShowVersion, "version", s.ShowVersion, "If localkube should just print the version and exit.")
|
||||
flag.BoolVar(&s.ShowHostIP, "host-ip", s.ShowHostIP, "If localkube should just print the host IP and exit.")
|
||||
flag.Var(&s.RuntimeConfig, "runtime-config", "A set of key=value pairs that describe runtime configuration that may be passed to apiserver. apis/<groupVersion> key can be used to turn on/off specific api versions. apis/<groupVersion>/<resource> can be used to turn on/off specific resources. api/all and api/legacy are special keys to control all and legacy api versions respectively.")
|
||||
flag.IPVar(&s.NodeIP, "node-ip", s.NodeIP, "IP address of the node. If set, kubelet will use this IP address for the node.")
|
||||
flag.StringVar(&s.ContainerRuntime, "container-runtime", "", "The container runtime to be used")
|
||||
|
|
|
@ -40,6 +40,12 @@ func StartLocalkube() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
if Server.ShowHostIP {
|
||||
hostIP, _ := Server.GetHostIP()
|
||||
fmt.Println("localkube host ip: ", hostIP.String())
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Get the etcd logger for the api repo
|
||||
apiRepoLogger := capnslog.MustRepoLogger("github.com/coreos/etcd/etcdserver/api")
|
||||
// Set the logging level to NOTICE as there is an INFO lvl log statement that runs every few seconds -> log spam
|
||||
|
@ -95,6 +101,10 @@ func SetupServer(s *localkube.LocalkubeServer) {
|
|||
}
|
||||
s.AddServer(etcd)
|
||||
|
||||
// setup access to etcd
|
||||
netIP, _ := s.GetHostIP()
|
||||
fmt.Printf("localkube host ip address: %s\n", netIP.String())
|
||||
|
||||
// setup apiserver
|
||||
apiserver := s.NewAPIServer()
|
||||
s.AddServer(apiserver)
|
||||
|
|
|
@ -35,10 +35,10 @@ const (
|
|||
|
||||
var (
|
||||
// EtcdClientURLs have listeners created and handle etcd API traffic
|
||||
KubeEtcdClientURLs = []string{"http://localhost:2379"}
|
||||
KubeEtcdClientURLs = []string{"http://0.0.0.0:2379"}
|
||||
|
||||
// EtcdPeerURLs don't have listeners created for them, they are used to pass Etcd validation
|
||||
KubeEtcdPeerURLs = []string{"http://localhost:2380"}
|
||||
KubeEtcdPeerURLs = []string{"http://0.0.0.0:2380"}
|
||||
)
|
||||
|
||||
// Etcd is a Server which manages an Etcd cluster
|
||||
|
|
|
@ -52,6 +52,7 @@ type LocalkubeServer struct {
|
|||
APIServerInsecurePort int
|
||||
ShouldGenerateCerts bool
|
||||
ShowVersion bool
|
||||
ShowHostIP bool
|
||||
RuntimeConfig config.ConfigurationMap
|
||||
NodeIP net.IP
|
||||
ContainerRuntime string
|
||||
|
|
Loading…
Reference in New Issue