Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

up: copy configs to remote host #19383

Merged
merged 1 commit into from
Apr 18, 2018

Conversation

mfojtik
Copy link
Contributor

@mfojtik mfojtik commented Apr 17, 2018

WARNING: Crazy ahead.

This is will enable the cluster up case where the Docker is running on a remote host (a DOCKER_HOST is used), which is typically a case on Windows and OSX (if not DockerForMac is used).

The way this works is that we are copying the generated configs to remote host via privileged Docker container.

Current cluster up code assumes that every config live on the host, this PR will make it less obvious and you will have to be careful which path you want to use. I spend a lot of time and a lot of cluster up runs to tweak all places where we generate the local files and need to copy them into host. This might even less obvious for the components and we will have to be careful on adding components to not forget copy the files they generate to remote...

I tested this code on OSX where I run the centos7 VM and exposing the Docker from that VM via DOCKER_HOST.

/cc @smarterclayton @praveenkumar

@deads2k I don't like this, but I can't think of a better way to do this :-(

Fixes: #19360
Fixes: #19154

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 17, 2018
@@ -133,6 +134,7 @@ func (c *ClusterUpConfig) StartSelfHosted(out io.Writer) error {
return err
}

clientConfig.Host = c.ServerIP + ":8443"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deads2k not sure if this is needed, but without this I was not able to get the --public-hostname to work. In order to bind the cluster up on the VM, I had to specify the VM IP address...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deads2k also I think I saw somebody on IRC reporting that --public-hostname is broken

@@ -282,7 +334,7 @@ func (c *ClusterUpConfig) makeMasterConfig() (string, error) {
container.MasterImage = c.openshiftImage()
container.Args = []string{
"--write-config=/var/lib/origin/openshift.local.config",
"--master=127.0.0.1",
fmt.Sprintf("--master=%s", c.ServerIP),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deads2k not sure if this fixes the comment above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deads2k not sure if this fixes the comment above.

You had to change this because you needed to serve from a different nic

@mfojtik mfojtik changed the title up: copy configs into remote host up: copy configs to remote host Apr 17, 2018
@mfojtik
Copy link
Contributor Author

mfojtik commented Apr 17, 2018

/hold

Need to also handle volumes, right now the directory is created into /Users/mfojtik/... in the host. It should all live in /var/lib/origin

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 17, 2018
if err != nil {
return nil, err
}
configs.openshiftControllerConfigDir, err = c.copyToRemote(configs.openshiftControllerConfigDir, kubeapiserver.OpenShiftControllerManagerDirName)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deads2k the reason I have to do this after every step is that some steps depend on files produced by previous step...

@mfojtik mfojtik force-pushed the up-40-volumes branch 2 times, most recently from 14f13b6 to 67d0c86 Compare April 17, 2018 11:54
@mfojtik
Copy link
Contributor Author

mfojtik commented Apr 17, 2018

problem with volume and data dir solved.

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 17, 2018
@@ -111,7 +111,9 @@ func NewCmdAdd(name, fullName string, out, errout io.Writer) *cobra.Command {
// Start runs the start tasks ensuring that they are executed in sequence
func (c *ClusterAddConfig) Run() error {
componentsToInstall := []componentinstall.Component{}
installContext, err := componentinstall.NewComponentInstallContext(c.openshiftImage(), c.imageFormat(), c.BaseDir, c.ServerLogLevel)
dockerHelper := dockerhelper.NewHelper(c.dockerClient)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't want this in the context. Can't we continue passing it through the install step?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 fixed.

@@ -17,24 +20,25 @@ nsenter --mount=/rootfs/proc/1/ns/mnt mkdir -p %[1]s
grep -F %[1]s /rootfs/proc/1/mountinfo || nsenter --mount=/rootfs/proc/1/ns/mnt mount -o bind %[1]s %[1]s
grep -F %[1]s /rootfs/proc/1/mountinfo | grep shared || nsenter --mount=/rootfs/proc/1/ns/mnt mount --make-shared %[1]s
`

// RemoteHostOriginDir is a directory on the remote machine that runs Docker
RemoteHostOriginDir = "/var/lib/origin"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary. Can't you just make the filesystem match the user filesystem. This was the source of a lot of ugly before and this is going to cause conflicts when you try to run with two different configs in two different CWDs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per IRC, I reworked this to be RemoteHostOriginDir + baseDir

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I really don't want to mess up with SELinux or something similar when mirroring the OSX filesystem tree)

@@ -48,7 +50,13 @@ func (r *RegistryComponentOptions) Install(dockerClient dockerhelper.Interface,
return err
}

masterConfigDir := path.Join(r.InstallContext.BaseDir(), kubeapiserver.KubeAPIServerDirName)
// If docker is on remote host, the base dir is different.
baseDir := r.InstallContext.BaseDir()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the isntallcontext to list a different basedir perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the baseDir should be the same, if you are talking to remote host, you just need to prefix

// the Docker host master config dir.
if len(os.Getenv("DOCKER_HOST")) > 0 {
hostHelper := host.NewHostHelper(c.InstallContext.DockerHelper(), c.InstallContext.ClientImage())
remoteMasterConfigDir := path.Join(host.RemoteHostOriginDir, kubeapiserver.KubeAPIServerDirName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should not be copying into this destination. The add on components don't get to mess with the running kube/openshift control plane. Copy to the remote host if you must, but this should be a different directory off the basedir. Perhaps I didn't notice when I was fixing the rest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was pre-existing (we generated the cert in the master config dir)... I can move this somewhere else.

if _, err := os.Stat(configLocations.openshiftAPIServerConfigDir); os.IsNotExist(err) {
_, err = c.makeOpenShiftAPIServerConfig(configLocations.masterConfigDir)
if c.isRemoteDocker {
configs.masterConfigDir, err = c.copyToRemote(configs.masterConfigDir, kubeapiserver.KubeAPIServerDirName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this value gets overwritten to be something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it will become the remote host dir

_, err = c.makeOpenShiftControllerConfig(configLocations.masterConfigDir)

if _, err := os.Stat(configs.nodeConfigDir); os.IsNotExist(err) {
_, err = c.makeNodeConfig(configs.masterConfigDir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this one get the remote master config dir?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it ran in container on remote host? (so it needs the remote masterConfigDir to get admin.kubeconfig (if I remember this one)

@mfojtik
Copy link
Contributor Author

mfojtik commented Apr 17, 2018

@deads2k added support for multiple CWD (will use baseDir as part of remote host path), removed the docker helper from context.

@mfojtik
Copy link
Contributor Author

mfojtik commented Apr 17, 2018

/retest

(centos mirrors are down, again)

@deads2k
Copy link
Contributor

deads2k commented Apr 17, 2018

Well, it's nasty. All installers are ugly. If you want it, I can deal with it, but hopefully we don't have to touch it much.

/lgtm
/retest

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 17, 2018
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, mfojtik

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit bb34ae4 into openshift:master Apr 18, 2018
@smarterclayton
Copy link
Contributor

smarterclayton commented Apr 18, 2018 via email

@mfojtik mfojtik deleted the up-40-volumes branch September 5, 2018 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants