-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/openshift-install/upi: Add a user-provided-infrastructure subcommand
To support the workflow described in upiLong. I've also replaced openshiftcorp.com with example.com to comply with [1]. That way readers don't need to worry about whether openshiftcorp.com exists and, if so, who owns it. I've updated the docs/user/aws/install.md examples to follow our current (with this PR) output: $ curl -s https://storage.googleapis.com/origin-ci-test/pr-logs/pull/openshift_installer/1393/pull-ci-openshift-installer-master-e2e-aws/4457/artifacts/e2e-aws/installer/.openshift_install.log | grep level=info | head -n13 time="2019-03-12T16:34:33Z" level=info msg="Consuming \"Install Config\" from target directory" time="2019-03-12T16:34:33Z" level=info msg="Creating cluster..." time="2019-03-12T16:51:21Z" level=info msg="Waiting up to 30m0s for the Kubernetes API at https://api.ci-op-j33s61i6-1d3f3.origin-ci-int-aws.dev.rhcloud.com:6443..." time="2019-03-12T16:55:29Z" level=info msg="API v1.12.4+341c822 up" time="2019-03-12T16:55:29Z" level=info msg="Waiting up to 30m0s for the bootstrap-complete event..." time="2019-03-12T17:04:56Z" level=info msg="Destroying the bootstrap resources..." time="2019-03-12T17:05:36Z" level=info msg="Waiting up to 30m0s for the cluster at https://api.ci-op-j33s61i6-1d3f3.origin-ci-int-aws.dev.rhcloud.com:6443 to initialize..." time="2019-03-12T17:14:56Z" level=info msg="Waiting up to 10m0s for the openshift-console route to be created..." time="2019-03-12T17:14:56Z" level=info msg="Install complete!" time="2019-03-12T17:14:56Z" level=info msg="Run 'export KUBECONFIG=/tmp/artifacts/installer/auth/kubeconfig' to manage the cluster with 'oc', the OpenShift CLI." time="2019-03-12T17:14:56Z" level=info msg="The cluster is ready when 'oc login -u kubeadmin -p 3MJb2-RRTfu-SKyuq-5NcCb' succeeds (wait a few minutes)." time="2019-03-12T17:14:56Z" level=info msg="Access the OpenShift web-console here: https://console-openshift-console.apps.ci-op-j33s61i6-1d3f3.origin-ci-int-aws.dev.rhcloud.com" time="2019-03-12T17:14:56Z" level=info msg="Login to the console with user: kubeadmin, password: 3MJb2-RRTfu-SKyuq-5NcCb" [1]: https://tools.ietf.org/html/rfc6761#section-6.5
- Loading branch information
Showing
5 changed files
with
129 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"path/filepath" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"k8s.io/client-go/tools/clientcmd" | ||
) | ||
|
||
var ( | ||
upiLong = `Entry-points for user-provided infrastructure. | ||
Most users will want to use 'create cluster' to have the installer | ||
create the required infrastructure for their cluster. But in some | ||
installations the infrastructure needs to be adapted in ways that | ||
installer-created infrastructure does not support. This command | ||
provides entry points to support the following workflow: | ||
1. Call 'create ignition-configs' to create the bootstrap Ignition | ||
config and admin kubeconfig. | ||
2. Creates all required cluster resources, after which the cluster | ||
will being bootstrapping. | ||
3. Call 'user-provided-infrastructure bootstrap-complete' to wait | ||
until the bootstrap phase has completed. | ||
4. Destroy the bootstrap resources. | ||
5. Call 'user-provided-infrastructure finish' to wait until the | ||
cluster finishes deploying its initial version. This also | ||
retrieves the router certificate authority from the cluster and | ||
inserts it into the admin kubeconfig.` | ||
) | ||
|
||
func newUPICmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "user-provided-infrastructure", | ||
Aliases: []string{"upi"}, | ||
Short: "Entry-points for user-provided infrastructure", | ||
Long: upiLong, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return cmd.Help() | ||
}, | ||
} | ||
cmd.AddCommand(newUPIBootstrapCompleteCmd()) | ||
cmd.AddCommand(newUPIFinishCmd()) | ||
return cmd | ||
} | ||
|
||
func newUPIBootstrapCompleteCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "bootstrap-complete", | ||
Short: "Wait until cluster bootstrapping has completed", | ||
Args: cobra.ExactArgs(0), | ||
Run: func(_ *cobra.Command, _ []string) { | ||
ctx := context.Background() | ||
|
||
cleanup := setupFileHook(rootOpts.dir) | ||
defer cleanup() | ||
|
||
config, err := clientcmd.BuildConfigFromFlags("", filepath.Join(rootOpts.dir, "auth", "kubeconfig")) | ||
if err != nil { | ||
logrus.Fatal(errors.Wrap(err, "loading kubeconfig")) | ||
} | ||
|
||
err = waitForBootstrapComplete(ctx, config, rootOpts.dir) | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
|
||
logrus.Info("It is now safe to remove the bootstrap resources") | ||
}, | ||
} | ||
} | ||
|
||
func newUPIFinishCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "finish", | ||
Short: "Wait for the cluster to finish updating and update local resources", | ||
Args: cobra.ExactArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
ctx := context.Background() | ||
|
||
cleanup := setupFileHook(rootOpts.dir) | ||
defer cleanup() | ||
|
||
config, err := clientcmd.BuildConfigFromFlags("", filepath.Join(rootOpts.dir, "auth", "kubeconfig")) | ||
if err != nil { | ||
logrus.Fatal(errors.Wrap(err, "loading kubeconfig")) | ||
} | ||
|
||
err = finish(ctx, config, rootOpts.dir) | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters