Skip to content

Commit

Permalink
Merge branch 'master' into feature/create-container-with-given-ID
Browse files Browse the repository at this point in the history
  • Loading branch information
wangforthinker authored Sep 12, 2018
2 parents 95612ed + 270093c commit f8bdc3d
Show file tree
Hide file tree
Showing 65 changed files with 1,172 additions and 545 deletions.
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ env:
- TEST_SUITE=integrationtest
- TEST_SUITE=criv1alpha1test
- TEST_SUITE=criv1alpha2test
- TEST_SUITE=nodee2etest

script: |
set -e # fast fail
Expand All @@ -43,14 +44,22 @@ script: |
sudo env "PATH=$PATH" make download-dependencies
sudo env "PATH=$PATH" make cri-v1alpha1-test
make coverage
else
elif [[ "${TEST_SUITE}" = "criv1alpha2test" ]]; then
make build
TEST_FLAGS= make build-daemon-integration
sudo env "PATH=$PATH" make install
sudo env "PATH=$PATH" make download-dependencies
sudo env "PATH=$PATH" make cri-v1alpha2-test
make coverage
else
make build
TEST_FLAGS= make build-daemon-integration
sudo env "PATH=$PATH" make install
sudo env "PATH=$PATH" make download-dependencies
sudo env "PATH=$PATH" make cri-e2e-test
make coverage
fi
after_success:
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mengjiahao <[email protected]>
Michael Wan <[email protected]>
mozhuli <[email protected]>
mx <[email protected]>
Oliver Frommel <[email protected]>
Penghao Cen <[email protected]>
pouchrobot <[email protected]>
pouch_robot <[email protected]>
Expand Down Expand Up @@ -107,6 +108,7 @@ ZeroMagic <[email protected]>
Zhanchun Zhang <[email protected]>
Zhang Min <[email protected]>
Zhang Zhanchun <[email protected]>
zhangyue <[email protected]>
zheng chen <[email protected]>
zheng chen <[email protected]>
zhuangqh <[email protected]>
Expand Down
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright The PouchContainer Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# TEST_FLAGS used as flags of go test.
TEST_FLAGS ?= -v --race

Expand All @@ -16,6 +30,13 @@ INTEGRATION_TESTCASE_BINARY_NAME=pouchd-integration-test
# DEST_DIR is base path used to install pouch & pouchd
DEST_DIR=/usr/local

# PREFIX is base path to install pouch & pouchd
# PREFIX will override the value of DEST_DIR when specified
# example: make install PREFIX=/usr
ifdef PREFIX
DEST_DIR := $(PREFIX)
endif

# the following variables used for the daemon build

# API_VERSION is used for daemon API Version in go build.
Expand Down Expand Up @@ -157,8 +178,14 @@ cri-v1alpha2-test: ## run v1 alpha2 cri-v1alpha2-test
@mkdir -p coverage
./hack/testing/run_daemon_cri_integration.sh v1alpha2

.PHONY: cri-e2e-test
cri-e2e-test: ## run cri-e2e-test
@echo $@
@mkdir -p coverage
./hack/testing/run_daemon_cri_e2e.sh v1alpha2

.PHONY: test
test: unit-test integration-test cri-v1alpha1-test cri-v1alpha2-test ## run the unit-test, integration-test , cri-v1alpha1-test and cri-v1alpha2-test
test: unit-test integration-test cri-v1alpha1-test cri-v1alpha2-test cri-e2e-test ## run the unit-test, integration-test , cri-v1alpha1-test , cri-v1alpha2-test and cri-e2e-test

.PHONY: coverage
coverage: ## combine coverage after test
Expand Down
52 changes: 43 additions & 9 deletions VAGRANT.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Vagrant support for pouch
# Vagrant support for PouchContainer

You can using Vagrant to quickly experience pouch or cross compile on non-linux.
You can using [Vagrant](https://www.vagrantup.com) to quickly experience PouchContainer or cross compile on non-linux.

## Requirements

* Vagrant 1.9.x or newer
* VirtuaBox

## Get started
## Getting Started

```bash
vagrant up
Expand All @@ -18,22 +18,56 @@ pouch run -d --name nginx -p 80:80 nginx
curl http://localhost
```

## Build pouch with vagrant
## Getting Started with Kubernetes

```bash
# On macOS or Linux
POUCH_KUBE=true vagrant up

# On MacOS or Linux
export POUCH_BUILD=true
# On Windows
set POUCH_KUBE=true
vagrant up

vagrant ssh -c "sudo -i"

$ kubectl cluster-info
Kubernetes master is running at https://10.0.2.15:6443
KubeDNS is running at https://10.0.2.15:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy


$ kubectl get cs
NAME STATUS MESSAGE
controller-manager Healthy ok
scheduler Healthy ok
etcd-0 Healthy {"health": "true"}

$ kubectl get po -o wide --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE
default nginx-6dc97b4cbd-cq4pb 1/1 Running 0 2m 10.244.0.2 pouch
default nginx-6dc97b4cbd-ktlwc 1/1 Running 0 2m 10.244.0.3 pouch
kube-system etcd-pouch 1/1 Running 0 3m 10.0.2.15 pouch
kube-system kube-apiserver-pouch 1/1 Running 0 2m 10.0.2.15 pouch
kube-system kube-controller-manager-pouch 1/1 Running 0 2m 10.0.2.15 pouch
kube-system kube-dns-b4bd9576-gwqzv 3/3 Running 0 2m 10.244.0.4 pouch
kube-system kube-flannel-ds-amd64-vd466 1/1 Running 1 2m 10.0.2.15 pouch
kube-system kube-proxy-c8l8j 1/1 Running 0 2m 10.0.2.15 pouch
kube-system kube-scheduler-pouch 1/1 Running 0 2m 10.0.2.15 pouch
```

## Build pouch with vagrant

```bash
# On macOS or Linux
POUCH_BUILD=true vagrant up

# On Windows
set POUCH_BUILD=true
vagrant up

# Install compiled pouch binarys for pouch service.
# Install compiled pouch binaries for pouch service.
vagrant ssh -c "sudo -i"
cd ~/go/src/github.com/alibaba/pouch
make DEST_DIR=/usr install
make PREFIX=/usr install
systemctl restart pouch
pouch version
```
```
29 changes: 28 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Vagrant.configure("2") do |config|
config.vm.define :pouch do |pouch|
pouch.vm.hostname = "pouch"
pouch.vm.box = "ubuntu/xenial64"
pouch.vm.provider 'virtualbox' do |v, override|
v.memory = 2048
end

pouch.vm.provision "shell", inline: <<-SHELL
until apt-get update &> /dev/null; do echo "Waiting apt-get for 3 seconds..."; sleep 3; done
apt-get --no-install-recommends install lxcfs
Expand Down Expand Up @@ -40,8 +44,31 @@ Vagrant.configure("2") do |config|
mkdir -p $GOPATH/src/github.com/alibaba
ln -s /vagrant $GOPATH/src/github.com/alibaba/pouch
cd $GOPATH/src/github.com/alibaba/pouch && make install
cd $GOPATH/src/github.com/alibaba/pouch
make PREFIX=/usr install
systemctl restart pouch
SHELL
end

if ENV["POUCH_KUBE"] == "true"
env = {
"KUBERNETES_VERSION" => "1.10",
"CRI_VERSION" => "v1alpha2",
"RELEASE_UBUNTU" => "v1.10.2",
"MASTER_NODE" => "true",
"INSTALL_FLANNEL" => "true",
"INSTALL_SAMPLE" => "true"
}

if ENV["http_proxy"] != ""
proxy = ENV["http_proxy"]

env["http_proxy"] = proxy
env["https_proxy"] = proxy
env["no_proxy"] = "localhost,127.0.0.1,10.96.0.0/16,10.0.0.0/16,10.244.0.0/16"
end

pouch.vm.provision "install_kubernetes", type: "shell", path: "hack/kubernetes/allinone_aliyun.sh", env: env
end
end
end
2 changes: 2 additions & 0 deletions apis/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ func HandleErrorResponse(w http.ResponseWriter, err error) {
code = http.StatusBadRequest
} else if errtypes.IsAlreadyExisted(err) {
code = http.StatusConflict
} else if errtypes.IsNotModified(err) {
code = http.StatusNotModified
}

w.Header().Set("Content-Type", "application/json")
Expand Down
2 changes: 2 additions & 0 deletions apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ paths:
responses:
204:
description: "no error"
304:
description: "container already started"
404:
$ref: "#/responses/404ErrorResponse"
409:
Expand Down
5 changes: 2 additions & 3 deletions cli/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (
)

// execDescription is used to describe exec command in detail and auto generate command doc.
// TODO: add description
var execDescription = ""
var execDescription = "Run a command in a running container"

// ExecCommand is used to implement 'exec' command.
type ExecCommand struct {
Expand All @@ -33,7 +32,7 @@ func (e *ExecCommand) Init(c *Cli) {
e.cli = c
e.cmd = &cobra.Command{
Use: "exec [OPTIONS] CONTAINER COMMAND [ARG...]",
Short: "Exec a process in a running container",
Short: "Run a command in a running container",
Long: execDescription,
Args: cobra.MinimumNArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
10 changes: 4 additions & 6 deletions cli/generate_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import (
)

// genDocDescription is used to describe gen-doc command in detail and auto generate command doc.
// TODO: add description
var genDocDescription = ""
var genDocDescription = "Generate docs for cli command"

// GenDocCommand is used to implement 'exec' command.
// GenDocCommand is used to implement 'gen-doc' command.
type GenDocCommand struct {
baseCommand
}

// Init initializes ExecCommand command.
// Init initializes GenDocCommand command.
func (g *GenDocCommand) Init(c *Cli) {
g.cli = c
g.cmd = &cobra.Command{
Expand Down Expand Up @@ -48,7 +47,6 @@ func (g *GenDocCommand) runGenDoc(args []string) error {
}

// genDocExample shows examples in genDoc command, and is used in auto-generated cli docs.
// TODO: add example
func genDocExample() string {
return ""
return "$ pouch gen-doc"
}
17 changes: 15 additions & 2 deletions cli/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var validDrivers = map[string]bool{
}

// logsDescription is used to describe logs command in detail and auto generate command doc.
var logsDescription = ""
var logsDescription = "Get container's logs"

// LogsCommand use to implement 'logs' command, it is used to print a container's logs
type LogsCommand struct {
Expand Down Expand Up @@ -97,5 +97,18 @@ func (lc *LogsCommand) runLogs(args []string) error {

// logsExample shows examples in logs command, and is used in auto-generated cli docs.
func logsExample() string {
return ``
return `$ pouch ps
Name ID Status Created Image Runtime
073f29 073f29 Up 1 day 2 days ago registry.hub.docker.com/library/redis:latest runc
$ pouch logs 073f29
1:C 04 Sep 05:42:01.600 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 04 Sep 05:42:01.601 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 04 Sep 05:42:01.601 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 04 Sep 05:42:01.601 * Increased maximum number of open files to 10032 (it was originally set to 1024).
1:M 04 Sep 05:42:01.602 * Running mode=standalone, port=6379.
1:M 04 Sep 05:42:01.602 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 04 Sep 05:42:01.602 # Server initialized
1:M 04 Sep 05:42:01.602 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 04 Sep 05:42:01.602 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
1:M 04 Sep 05:42:01.602 * Ready to accept connections`
}
8 changes: 7 additions & 1 deletion cli/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,11 @@ func (rc *RestartCommand) runRestart(args []string) error {

// restartExample shows examples in restart command, and is used in auto-generated cli docs.
func restartExample() string {
return `//TODO`
return `$ pouch ps -a
Name ID Status Image Runtime
foo 71b9c1 Stopped docker.io/library/busybox:latest runc
$ pouch restart foo
$ pouch ps
Name ID Status Image Runtime
foo 71b9c1 Running docker.io/library/busybox:latest runc`
}
4 changes: 2 additions & 2 deletions cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ func (rc *RunCommand) runRun(args []string) error {
func runExample() string {
return `$ pouch run --name test registry.hub.docker.com/library/busybox:latest echo "hi"
hi
$ pouch ps
$ pouch ps -a
Name ID Status Image Runtime Created
test 23f852 stopped registry.hub.docker.com/library/busybox:latest runc 4 seconds ago
$ pouch run -d --name test registry.hub.docker.com/library/busybox:latest
90719b5f9a455b3314a49e72e3ecb9962f215e0f90153aa8911882acf2ba2c84
$ pouch ps
$ pouch ps -a
Name ID Status Image Runtime Created
test 90719b stopped registry.hub.docker.com/library/busybox:latest runc 5 seconds ago
$ pouch run --device /dev/zero:/dev/testDev:rwm --name test registry.hub.docker.com/library/busybox:latest ls -l /dev/testDev
Expand Down
2 changes: 1 addition & 1 deletion cli/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func stopExample() string {
Name ID Status Image Runtime
foo 71b9c1 Running docker.io/library/busybox:latest runc
$ pouch stop foo
$ pouch ps
$ pouch ps -a
Name ID Status Image Runtime
foo 71b9c1 Stopped docker.io/library/busybox:latest runc`
}
2 changes: 1 addition & 1 deletion cli/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// upgradeDescription is used to describe upgrade command in detail and auto generate command doc.
var upgradeDescription = ""
var upgradeDescription = "Upgrade a container with new image and args"

// UpgradeCommand use to implement 'upgrade' command, it is used to upgrade a container.
type UpgradeCommand struct {
Expand Down
3 changes: 3 additions & 0 deletions cri/annotations/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ const (

// KubernetesRuntime is the runtime
KubernetesRuntime = "io.kubernetes.runtime"

// LxcfsEnabled whether to enable lxcfs for a container
LxcfsEnabled = "io.kubernetes.lxcfs.enabled"
)
10 changes: 9 additions & 1 deletion cri/v1alpha1/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,15 @@ func (c *CriManager) CreateContainer(ctx context.Context, r *runtime.CreateConta
sandboxRootDir := path.Join(c.SandboxBaseDir, podSandboxID)
createConfig.HostConfig.Binds = append(createConfig.HostConfig.Binds, generateContainerMounts(sandboxRootDir)...)

// TODO: devices and security option configurations.
var devices []*apitypes.DeviceMapping
for _, device := range config.Devices {
devices = append(devices, &apitypes.DeviceMapping{
PathOnHost: device.HostPath,
PathInContainer: device.ContainerPath,
CgroupPermissions: device.Permissions,
})
}
createConfig.HostConfig.Resources.Devices = devices

containerName := makeContainerName(sandboxConfig, config)

Expand Down
Loading

0 comments on commit f8bdc3d

Please sign in to comment.