build gvisor image locally in integration tests; add temporary error to make sure that image is used
parent
5688e17d73
commit
d2e5a4b052
2
Makefile
2
Makefile
|
@ -381,7 +381,7 @@ out/gvisor-addon:
|
|||
GOOS=linux CGO_ENABLED=0 go build -o $@ cmd/gvisor/gvisor.go
|
||||
|
||||
.PHONY: gvisor-addon-image
|
||||
gvisor-addon-image: out/gvisor-addon
|
||||
gvisor-addon-image:
|
||||
docker build -t $(REGISTRY)/gvisor-addon:latest -f deploy/gvisor/Dockerfile .
|
||||
|
||||
.PHONY: push-gvisor-addon-image
|
||||
|
|
|
@ -24,7 +24,7 @@ spec:
|
|||
hostPID: true
|
||||
containers:
|
||||
- name: gvisor
|
||||
image: {{default "gcr.io/k8s-minikube" .GvisorImageRepo}}/gvisor-addon:latest
|
||||
image: {{default "gcr.io/k8s-minikube" .ImageRepository}}/gvisor-addon:latest
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
|
|
|
@ -12,9 +12,15 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM golang:1.12.5
|
||||
WORKDIR $GOPATH/src/k8s.io/minikube
|
||||
COPY . .
|
||||
ENV GO111MODULE=on
|
||||
RUN GOOS=linux CGO_ENABLED=0 go build -o /out/gvisor-addon cmd/gvisor/gvisor.go
|
||||
|
||||
FROM ubuntu:18.04
|
||||
RUN apt-get update && \
|
||||
apt-get install -y kmod gcc wget xz-utils libc6-dev bc libelf-dev bison flex openssl libssl-dev libidn2-0 sudo libcap2 && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
COPY out/gvisor-addon /gvisor-addon
|
||||
COPY --from=0 /out/gvisor-addon /gvisor-addon
|
||||
CMD ["/gvisor-addon"]
|
||||
|
|
|
@ -44,6 +44,7 @@ const (
|
|||
// 3. copies necessary containerd config files
|
||||
// 4. restarts containerd
|
||||
func Enable() error {
|
||||
return fmt.Errorf("local image used correctly")
|
||||
if err := makeGvisorDirs(); err != nil {
|
||||
return errors.Wrap(err, "creating directories on node")
|
||||
}
|
||||
|
|
|
@ -403,12 +403,10 @@ func GenerateTemplateData(cfg config.KubernetesConfig) interface{} {
|
|||
Arch string
|
||||
ExoticArch string
|
||||
ImageRepository string
|
||||
GvisorImageRepo string
|
||||
}{
|
||||
Arch: a,
|
||||
ExoticArch: ea,
|
||||
ImageRepository: cfg.ImageRepository,
|
||||
GvisorImageRepo: os.Getenv(constants.MinikubeGvisorAddonImageRepo),
|
||||
}
|
||||
|
||||
return opts
|
||||
|
|
|
@ -431,8 +431,7 @@ const (
|
|||
// GvisorURL is the url to download gvisor
|
||||
GvisorURL = "https://storage.googleapis.com/gvisor/releases/nightly/2018-12-07/runsc"
|
||||
|
||||
// MinikubeGvisorAddonImageRepo is the environment variable set by integration tests to change the gvisor image repo.
|
||||
MinikubeGvisorAddonImageRepo = "MINIKUBE_GVISOR_ADDON_IMAGE_REPO"
|
||||
GvisorImage = "gcr.io/k8s-minikube/gvisor-addon:latest"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -19,13 +19,9 @@ limitations under the License.
|
|||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/machine/libmachine/state"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
|
@ -66,12 +62,8 @@ func TestFunctionalContainerd(t *testing.T) {
|
|||
r.RunCommand("delete", true)
|
||||
}
|
||||
|
||||
// Build and push new gvisor image for testing.
|
||||
repo := fmt.Sprintf("gcr.io/k8s-minikube/test/gvisor-image/%d", time.Now().Unix())
|
||||
pushGvisorImage(t, repo)
|
||||
|
||||
defer os.Setenv(constants.MinikubeGvisorAddonImageRepo, "")
|
||||
os.Setenv(constants.MinikubeGvisorAddonImageRepo, repo)
|
||||
// Build current version of the gvisor image.
|
||||
buildGvisorImage(t)
|
||||
|
||||
r.Start("--container-runtime=containerd", "--docker-opt containerd=/var/run/containerd/containerd.sock")
|
||||
t.Run("Gvisor", testGvisor)
|
||||
|
@ -79,10 +71,9 @@ func TestFunctionalContainerd(t *testing.T) {
|
|||
r.RunCommand("delete", true)
|
||||
}
|
||||
|
||||
func pushGvisorImage(t *testing.T, repo string) {
|
||||
cmd := exec.Command("make", "push-gvisor-addon-image")
|
||||
cmd.Env = append(os.Environ(), []string{fmt.Sprintf("REGISTRY=%s", repo)}...)
|
||||
cmd.Dir = filepath.Join(os.Getenv("GOPATH"), "src/k8s.io/minikube")
|
||||
func buildGvisorImage(t *testing.T) {
|
||||
cmd := exec.Command("docker", "build", "-t", constants.GvisorImage, "-f", "deploy/gvisor/Dockerfile", ".")
|
||||
cmd.Dir = "../../"
|
||||
stdout, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("Error running command: %s in directory: %s %v. Output: %s", cmd.Args, cmd.Dir, err, string(stdout))
|
||||
|
|
Loading…
Reference in New Issue