如何让oc集群持久化?
How to make oc cluster up persistent?
我正在使用 "oc cluster up" 启动我的 Openshift Origin 环境。但是,我可以看到,一旦我关闭集群,我的项目就不会在重新启动时保留下来。有没有办法让他们持久?
谢谢
有几种方法可以做到这一点。 oc cluster up 没有持久化资源的主要用例。
有几种方法可以做到:
- 如 oc cluster up README
中所述利用捕获 etcd
- 有一个 wrapper tool,可以很容易地做到这一点。
cluster up --help
命令中现在有一个示例,它一定会保持最新状态,因此请首先检查
oc cluster up --help
...
Examples:
# Start OpenShift on a new docker machine named 'openshift'
oc cluster up --create-machine
# Start OpenShift using a specific public host name
oc cluster up --public-hostname=my.address.example.com
# Start OpenShift and preserve data and config between restarts
oc cluster up --host-data-dir=/mydata --use-existing-config
所以特别是在 v1.3.2
中使用 --host-data-dir
和 --use-existing-config
假设您正在使用 docker 机器和 vm,例如 virtual box,我发现最简单的方法是在 vm 和 openshift 集群启动并 运行ning 时拍摄 vm 快照。此快照将备份内存和磁盘,因此您可以稍后通过还原 vm 快照来还原整个集群,然后 运行 docker-machine start ...
顺便说一句,从最新的 os 图像 openshift/origin:v3.6.0-rc.0 和 oc cli 开始,其他答案中建议的 --host-data-dir=/mydata
对我不起作用.
我正在使用:
虚拟盒子 5.1.26
Kubernetes v1.5.2+43a9be4
openshift v1.5.0+031cbe4
使用 --host-data-dir(和其他)对我不起作用:
oc cluster up --logging=true --metrics=true --docker-machine=openshift --use-existing-config=true --host-data-dir=/vm/data --host-config-dir=/vm/config --host-pv-dir=/vm/pv --host-volumes-dir=/vm/volumes
输出:
-- Checking OpenShift client ... OK
-- Checking Docker client ...
Starting Docker machine 'openshift'
Started Docker machine 'openshift'
-- Checking Docker version ...
WARNING: Cannot verify Docker version
-- Checking for existing OpenShift container ... OK
-- Checking for openshift/origin:v1.5.0 image ... OK
-- Checking Docker daemon configuration ... OK
-- Checking for available ports ... OK
-- Checking type of volume mount ...
Using Docker shared volumes for OpenShift volumes
-- Creating host directories ... OK
-- Finding server IP ...
Using docker-machine IP 192.168.99.100 as the host IP
Using 192.168.99.100 as the server IP
-- Starting OpenShift container ...
Starting OpenShift using container 'origin'
FAIL
Error: could not start OpenShift container "origin"
Details:
Last 10 lines of "origin" container log:
github.com/openshift/origin/vendor/github.com/coreos/pkg/capnslog.(*PackageLogger).Panicf(0xc4202a1600, 0x42b94c0, 0x1f, 0xc4214d9f08, 0x2, 0x2)
/go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/coreos/pkg/capnslog/pkg_logger.go:75 +0x16a
github.com/openshift/origin/vendor/github.com/coreos/etcd/mvcc/backend.newBackend(0xc4209f84c0, 0x33, 0x5f5e100, 0x2710, 0xc4214d9fa8)
/go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/coreos/etcd/mvcc/backend/backend.go:106 +0x341
github.com/openshift/origin/vendor/github.com/coreos/etcd/mvcc/backend.NewDefaultBackend(0xc4209f84c0, 0x33, 0x461e51, 0xc421471200)
/go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/coreos/etcd/mvcc/backend/backend.go:100 +0x4d
github.com/openshift/origin/vendor/github.com/coreos/etcd/etcdserver.NewServer.func1(0xc4204bf640, 0xc4209f84c0, 0x33, 0xc421079a40)
/go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/coreos/etcd/etcdserver/server.go:272 +0x39
created by github.com/openshift/origin/vendor/github.com/coreos/etcd/etcdserver.NewServer
/go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/coreos/etcd/etcdserver/server.go:274 +0x345
Openshift 写入目录 /vm/...(也在 VirtualBox 中定义)但无法成功启动。
参见 [https://github.com/openshift/origin/issues/12602][1]
也为我工作,使用 Virtual Box 快照并恢复它们。
要使其在每次关机后保持不变,您需要提供 base-dir
参数。
$ mkdir ~/openshift-config
$ oc cluster up --base-dir=~/openshift-config
来自帮助
$ oc cluster up --help
...
Options:
--base-dir='': Directory on Docker host for cluster up configuration
--enable=[*]: A list of components to enable. '*' enables all on-by-default components, 'foo' enables the component named 'foo', '-foo' disables the component named 'foo'.
--forward-ports=false: Use Docker port-forwarding to communicate with origin container. Requires 'socat' locally.
--http-proxy='': HTTP proxy to use for master and builds
--https-proxy='': HTTPS proxy to use for master and builds
--image='openshift/origin-${component}:${version}': Specify the images to use for OpenShift
--no-proxy=[]: List of hosts or subnets for which a proxy should not be used
--public-hostname='': Public hostname for OpenShift cluster
--routing-suffix='': Default suffix for server routes
--server-loglevel=0: Log level for OpenShift server
--skip-registry-check=false: Skip Docker daemon registry check
--write-config=false: Write the configuration files into host config dir
但是你不应该使用它,因为 "cluster up" 在 4.0.0 版本中被删除了。更多信息:https://github.com/openshift/origin/pull/21399
我正在使用 "oc cluster up" 启动我的 Openshift Origin 环境。但是,我可以看到,一旦我关闭集群,我的项目就不会在重新启动时保留下来。有没有办法让他们持久? 谢谢
有几种方法可以做到这一点。 oc cluster up 没有持久化资源的主要用例。
有几种方法可以做到:
- 如 oc cluster up README 中所述利用捕获 etcd
- 有一个 wrapper tool,可以很容易地做到这一点。
cluster up --help
命令中现在有一个示例,它一定会保持最新状态,因此请首先检查
oc cluster up --help
...
Examples:
# Start OpenShift on a new docker machine named 'openshift'
oc cluster up --create-machine
# Start OpenShift using a specific public host name
oc cluster up --public-hostname=my.address.example.com
# Start OpenShift and preserve data and config between restarts
oc cluster up --host-data-dir=/mydata --use-existing-config
所以特别是在 v1.3.2
中使用 --host-data-dir
和 --use-existing-config
假设您正在使用 docker 机器和 vm,例如 virtual box,我发现最简单的方法是在 vm 和 openshift 集群启动并 运行ning 时拍摄 vm 快照。此快照将备份内存和磁盘,因此您可以稍后通过还原 vm 快照来还原整个集群,然后 运行 docker-machine start ...
顺便说一句,从最新的 os 图像 openshift/origin:v3.6.0-rc.0 和 oc cli 开始,其他答案中建议的 --host-data-dir=/mydata
对我不起作用.
我正在使用:
虚拟盒子 5.1.26
Kubernetes v1.5.2+43a9be4
openshift v1.5.0+031cbe4
使用 --host-data-dir(和其他)对我不起作用:
oc cluster up --logging=true --metrics=true --docker-machine=openshift --use-existing-config=true --host-data-dir=/vm/data --host-config-dir=/vm/config --host-pv-dir=/vm/pv --host-volumes-dir=/vm/volumes
输出:
-- Checking OpenShift client ... OK
-- Checking Docker client ...
Starting Docker machine 'openshift'
Started Docker machine 'openshift'
-- Checking Docker version ...
WARNING: Cannot verify Docker version
-- Checking for existing OpenShift container ... OK
-- Checking for openshift/origin:v1.5.0 image ... OK
-- Checking Docker daemon configuration ... OK
-- Checking for available ports ... OK
-- Checking type of volume mount ...
Using Docker shared volumes for OpenShift volumes
-- Creating host directories ... OK
-- Finding server IP ...
Using docker-machine IP 192.168.99.100 as the host IP
Using 192.168.99.100 as the server IP
-- Starting OpenShift container ...
Starting OpenShift using container 'origin'
FAIL
Error: could not start OpenShift container "origin"
Details:
Last 10 lines of "origin" container log:
github.com/openshift/origin/vendor/github.com/coreos/pkg/capnslog.(*PackageLogger).Panicf(0xc4202a1600, 0x42b94c0, 0x1f, 0xc4214d9f08, 0x2, 0x2)
/go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/coreos/pkg/capnslog/pkg_logger.go:75 +0x16a
github.com/openshift/origin/vendor/github.com/coreos/etcd/mvcc/backend.newBackend(0xc4209f84c0, 0x33, 0x5f5e100, 0x2710, 0xc4214d9fa8)
/go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/coreos/etcd/mvcc/backend/backend.go:106 +0x341
github.com/openshift/origin/vendor/github.com/coreos/etcd/mvcc/backend.NewDefaultBackend(0xc4209f84c0, 0x33, 0x461e51, 0xc421471200)
/go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/coreos/etcd/mvcc/backend/backend.go:100 +0x4d
github.com/openshift/origin/vendor/github.com/coreos/etcd/etcdserver.NewServer.func1(0xc4204bf640, 0xc4209f84c0, 0x33, 0xc421079a40)
/go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/coreos/etcd/etcdserver/server.go:272 +0x39
created by github.com/openshift/origin/vendor/github.com/coreos/etcd/etcdserver.NewServer
/go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/coreos/etcd/etcdserver/server.go:274 +0x345
Openshift 写入目录 /vm/...(也在 VirtualBox 中定义)但无法成功启动。 参见 [https://github.com/openshift/origin/issues/12602][1]
也为我工作,使用 Virtual Box 快照并恢复它们。
要使其在每次关机后保持不变,您需要提供 base-dir
参数。
$ mkdir ~/openshift-config
$ oc cluster up --base-dir=~/openshift-config
来自帮助
$ oc cluster up --help
...
Options:
--base-dir='': Directory on Docker host for cluster up configuration
--enable=[*]: A list of components to enable. '*' enables all on-by-default components, 'foo' enables the component named 'foo', '-foo' disables the component named 'foo'.
--forward-ports=false: Use Docker port-forwarding to communicate with origin container. Requires 'socat' locally.
--http-proxy='': HTTP proxy to use for master and builds
--https-proxy='': HTTPS proxy to use for master and builds
--image='openshift/origin-${component}:${version}': Specify the images to use for OpenShift
--no-proxy=[]: List of hosts or subnets for which a proxy should not be used
--public-hostname='': Public hostname for OpenShift cluster
--routing-suffix='': Default suffix for server routes
--server-loglevel=0: Log level for OpenShift server
--skip-registry-check=false: Skip Docker daemon registry check
--write-config=false: Write the configuration files into host config dir
但是你不应该使用它,因为 "cluster up" 在 4.0.0 版本中被删除了。更多信息:https://github.com/openshift/origin/pull/21399