Skip to content

Commit

Permalink
Force out-of-cluster installation with Docker EE.
Browse files Browse the repository at this point in the history
  • Loading branch information
clintonk committed Sep 4, 2018
1 parent 045a8a2 commit 4629d79
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
19 changes: 19 additions & 0 deletions cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,15 @@ func discoverInstallationEnvironment() error {
useKubernetesRBAC = true
if ucpBearerToken != "" || ucpHost != "" {
useKubernetesRBAC = false

if ucpClient, err = ucpclient.NewClient(ucpHost, ucpBearerToken); err != nil {
return err
}

if inCluster {
log.Info("In-cluster installation is not supported with Docker EE, running outside cluster.")
inCluster = false
}
}

// Prepare input file paths
Expand Down Expand Up @@ -1634,6 +1640,19 @@ func installTridentInCluster() (returnError error) {
commandArgs = append(commandArgs, "--trident-image")
commandArgs = append(commandArgs, tridentImage)
}
if etcdImage != "" {
commandArgs = append(commandArgs, "--etcd-image")
commandArgs = append(commandArgs, etcdImage)
}
if ucpBearerToken != "" {
commandArgs = append(commandArgs, "--ucp-bearer-token")
commandArgs = append(commandArgs, ucpBearerToken)
}
if ucpHost != "" {
commandArgs = append(commandArgs, "--ucp-host")
commandArgs = append(commandArgs, ucpHost)
}
commandArgs = append(commandArgs, "--in-cluster=false")

// Create the install pod
returnError = client.CreateObjectByYAML(k8sclient.GetInstallerPodYAML(
Expand Down
21 changes: 20 additions & 1 deletion cli/cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func init() {
uninstallCmd.Flags().BoolVar(&csi, "csi", false, "Uninstall CSI Trident (alpha, not for production clusters).")
uninstallCmd.Flags().StringVar(&tridentImage, "trident-image", "", "The Trident image to use for an in-cluster uninstall operation.")
uninstallCmd.Flags().MarkHidden("trident-image")
uninstallCmd.Flags().BoolVar(&inCluster, "in-cluster", false, "Run the installer as a job in the cluster.")
uninstallCmd.Flags().BoolVar(&inCluster, "in-cluster", true, "Run the installer as a job in the cluster.")
uninstallCmd.Flags().MarkHidden("in-cluster")

uninstallCmd.Flags().StringVar(&ucpBearerToken, "ucp-bearer-token", "", "UCP authorization token (for Docker UCP only).")
Expand Down Expand Up @@ -90,9 +90,15 @@ func discoverUninstallationEnvironment() error {
useKubernetesRBAC = true
if ucpBearerToken != "" || ucpHost != "" {
useKubernetesRBAC = false

if ucpClient, err = ucpclient.NewClient(ucpHost, ucpBearerToken); err != nil {
return err
}

if inCluster {
log.Info("In-cluster uninstallation is not supported with Docker EE, running outside cluster.")
inCluster = false
}
}

// Infer installation namespace if not specified
Expand Down Expand Up @@ -449,6 +455,19 @@ func uninstallTridentInCluster() (returnError error) {
if csi {
commandArgs = append(commandArgs, "--csi")
}
if tridentImage != "" {
commandArgs = append(commandArgs, "--trident-image")
commandArgs = append(commandArgs, tridentImage)
}
if ucpBearerToken != "" {
commandArgs = append(commandArgs, "--ucp-bearer-token")
commandArgs = append(commandArgs, ucpBearerToken)
}
if ucpHost != "" {
commandArgs = append(commandArgs, "--ucp-host")
commandArgs = append(commandArgs, ucpHost)
}
commandArgs = append(commandArgs, "--in-cluster=false")

// Create the uninstall pod
returnError = client.CreateObjectByYAML(k8sclient.GetUninstallerPodYAML(
Expand Down
4 changes: 2 additions & 2 deletions cli/k8s_client/yaml_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ metadata:
name: trident-installer
rules:
- apiGroups: [""]
resources: ["namespaces", "pods", "pods/exec", "persistentvolumes", "persistentvolumeclaims", "secrets", "serviceaccounts", "services", "events", "nodes", "configmaps"]
resources: ["namespaces", "pods", "pods/exec", "persistentvolumes", "persistentvolumeclaims", "persistentvolumeclaims/status", "secrets", "serviceaccounts", "services", "events", "nodes", "configmaps"]
verbs: ["*"]
- apiGroups: ["extensions"]
resources: ["deployments", "daemonsets"]
Expand All @@ -877,7 +877,7 @@ metadata:
name: trident-installer
rules:
- apiGroups: [""]
resources: ["namespaces", "pods", "pods/exec", "persistentvolumes", "persistentvolumeclaims", "secrets", "serviceaccounts", "services", "events", "nodes", "configmaps"]
resources: ["namespaces", "pods", "pods/exec", "persistentvolumes", "persistentvolumeclaims", "persistentvolumeclaims/status", "secrets", "serviceaccounts", "services", "events", "nodes", "configmaps"]
verbs: ["*"]
- apiGroups: ["extensions"]
resources: ["deployments", "daemonsets"]
Expand Down

0 comments on commit 4629d79

Please sign in to comment.