Skip to content

Commit

Permalink
cmd/openshift-install/waitfor: Rename from user-provided-infrastructure
Browse files Browse the repository at this point in the history
There is no hard line between installer- and user-provided
infrastructure.  Rename these commands to focus on what they'll do
instead of the work-flow into which we expect them to fit.

We're still working out how we can drop the router-CA injection to
avoid 'wait-for cluster-ready' surprising users my editing their
on-disk kubeconfig [1].  But that's mitigated somewhat by the fact
that addRouterCAToClusterCA is idempotent, because AppendCertsFromPEM
wraps AddCert [2] and AddCert checks to avoid duplicate certificates
[3].

[1]: #1541
[2]: https://github.com/golang/go/blob/go1.12/src/crypto/x509/cert_pool.go#L144
[3]: https://github.com/golang/go/blob/go1.12/src/crypto/x509/cert_pool.go#L106-L109
  • Loading branch information
wking committed Apr 8, 2019
1 parent ee5d518 commit 8cd13c0
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 107 deletions.
4 changes: 2 additions & 2 deletions cmd/openshift-install/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var (
logrus.Fatal(err)
}

err = finish(ctx, config, rootOpts.dir)
err = waitForClusterReady(ctx, config, rootOpts.dir)
if err != nil {
logrus.Fatal(err)
}
Expand Down Expand Up @@ -433,7 +433,7 @@ func logComplete(directory, consoleURL string) error {
return nil
}

func finish(ctx context.Context, config *rest.Config, directory string) error {
func waitForClusterReady(ctx context.Context, config *rest.Config, directory string) error {
if err := waitForInitializedCluster(ctx, config); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/openshift-install/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func installerMain() {
for _, subCmd := range []*cobra.Command{
newCreateCmd(),
newDestroyCmd(),
newUPICmd(),
newWaitForCmd(),
newVersionCmd(),
newGraphCmd(),
newCompletionCmd(),
Expand Down
98 changes: 0 additions & 98 deletions cmd/openshift-install/upi.go

This file was deleted.

79 changes: 79 additions & 0 deletions cmd/openshift-install/waitfor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package main

import (
"context"
"path/filepath"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/clientcmd"
)

func newWaitForCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "wait-for",
Short: "Wait for install-time events",
Long: `Wait for install-time events.
'create cluster' has a few stages that wait for cluster events. But
these waits can also be useful on their own. This subcommand exposes
them directly.`,
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}
cmd.AddCommand(newWaitForBootstrapCompleteCmd())
cmd.AddCommand(newWaitForClusterReadyCmd())
return cmd
}

func newWaitForBootstrapCompleteCmd() *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 newWaitForClusterReadyCmd() *cobra.Command {
return &cobra.Command{
Use: "cluster-ready",
Short: "Wait until the cluster is ready",
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 = waitForClusterReady(ctx, config, rootOpts.dir)
if err != nil {
logrus.Fatal(err)
}
},
}
}
4 changes: 2 additions & 2 deletions docs/user/aws/install_upi.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ and load balancer configuration.
## Monitor for `bootstrap-complete` and Initialization

```console
$ bin/openshift-install user-provided-infrastructure bootstrap-complete
$ bin/openshift-install wait-for bootstrap-complete
INFO Waiting up to 30m0s for the Kubernetes API at https://api.test.example.com:6443...
INFO API v1.12.4+c53f462 up
INFO Waiting up to 30m0s for the bootstrap-complete event...
Expand Down Expand Up @@ -248,7 +248,7 @@ TODO: Identify changes needed to Router or Ingress for DNS `*.apps` registration
## Monitor for Cluster Completion

```console
$ bin/openshift-install user-provided-infrastructure finish
$ bin/openshift-install wait-for cluster-ready
INFO Waiting up to 30m0s for the cluster to initialize...
```

Expand Down
8 changes: 4 additions & 4 deletions docs/user/metal/install_upi.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,21 +202,21 @@ TODO RHEL CoreOS does not have assets for bare-metal.

### Monitor for bootstrap-complete

The administrators can use the `upi bootstrap-complete` target of the OpenShift Installer to monitor cluster bootstrapping. The command succeeds when it notices `bootstrap-complete` event from Kubernetes APIServer. This event is generated by the bootstrap machine after the Kubernetes APIServer has been bootstrapped on the control plane machines. For example,
The administrators can use the `wait-for bootstrap-complete` target of the OpenShift Installer to monitor cluster bootstrapping. The command succeeds when it notices `bootstrap-complete` event from Kubernetes APIServer. This event is generated by the bootstrap machine after the Kubernetes APIServer has been bootstrapped on the control plane machines. For example,

```console
$ openshift-install --dir test-bare-metal upi bootstrap-complete
$ openshift-install --dir test-bare-metal wait-for bootstrap-complete
INFO Waiting up to 30m0s for the Kubernetes API at https://api.test.example.com:6443...
INFO API v1.12.4+c53f462 up
INFO Waiting up to 30m0s for the bootstrap-complete event...
```

## Monitor for cluster completion

The administrators can use the `upi finish` target of the OpenShift Installer to monitor cluster completion. The command succeeds when it notices that Cluster Version Operator has completed rolling out the OpenShift cluster from Kubernetes APIServer.
The administrators can use the `wait-for cluster-ready` target of the OpenShift Installer to monitor cluster completion. The command succeeds when it notices that Cluster Version Operator has completed rolling out the OpenShift cluster from Kubernetes APIServer.

```console
$ openshift-install upi finish
$ openshift-install wait-for cluster-ready
INFO Waiting up to 30m0s for the cluster to initialize...
```

Expand Down

0 comments on commit 8cd13c0

Please sign in to comment.