kubernetes/minikube

Document minikube to minikube network communication (testing)

Open

#2,602 创建于 2018年3月13日

在 GitHub 查看
 (12 评论) (10 反应) (0 负责人)Go (31,799 star) (5,222 fork)batch import
help wantedkind/documentationlifecycle/frozenpriority/backlog

描述

Is this a BUG REPORT or FEATURE REQUEST? (choose one):

Feature request

I'd like to run minikube in one docker container and connect to it from another.

I'd like to be able to run an integration test layer using minikube, and have tests connect to minikube from the container, but the config minikube generates seems to use a random ip that complicates it.

version: "2"                                                                                                                        
services:
  minikube:                                                                                                                         
    image: minikube                                                                                                                 
    build:                                                                                                                          
      context: "."                                                                                                                  
      dockerfile: "docker/minikube"                                                                                                 
    volumes:                                                                                                                        
      - "/etc/ssl/certs:/etc/ssl/certs"                                                                                             
      - "/var/run/docker.sock:/var/run/docker.sock"                                                                                 
    privileged: true
  golang-tests:
    ...

Please provide the following details:

Environment:

Trying to run minikube in a docker container and connect to it from another docker container.

minikube version: v0.25.0 VM Driver = none ISO Version = v1.9.0

docker-compose version 1.18.0, build 8dd22a9 docker version: 1.13.1

What happened:

I'm unable to connect to minikube from another linked container via

kubectl get pods --server=minikube:8080

The connection to the server minikube:8080 was refused - did you specify the right host or port?

What you expected to happen:

A list of pods returned.

How to reproduce it (as minimally and precisely as possible):

With the docker file

FROM alpine:latest               

ADD https://storage.googleapis.com/kubernetes-release/release/v1.7.5/bin/linux/amd64/kubectl kubectl                                
RUN chmod +x kubectl             
ADD https://storage.googleapis.com/minikube/releases/v0.25.0/minikube-linux-amd64 minikube                                          
RUN chmod +x minikube            
ADD https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz docker-17.09.0-ce.tgz                              
RUN tar xzvf docker-17.09.0-ce.tgz                                

FROM debian:stable-slim          
COPY --from=0 kubectl minikube docker/docker /usr/local/bin/      
COPY start.sh start.sh                           
CMD ["sh", "./start.sh"]

start.sh

#!/bin/sh
/usr/local/bin/minikube start --vm-driver=none
/usr/local/bin/minikube logs -f

With the following docker-compose.yml

version: "2"                                                                                                                        
services:
  minikube:                                                                                                                         
    image: minikube                                                                                                                 
    build:                                                                                                                          
      context: "."                                                                                                                  
      dockerfile: "docker/minikube"                                                                                                 
    volumes:                                                                                                                        
      - "/etc/ssl/certs:/etc/ssl/certs"                                                                                             
      - "/var/run/docker.sock:/var/run/docker.sock"                                                                                 
    privileged: true
  get-pods:                                                                                                                           
    image: "google/cloud-sdk:190.0.1"                
    links: 
      - "minikube"                                                                                              
    command: ["kubectl","get","pods","--server=minikube:8080"]

run docker-compose run get-pods

贡献者指南