Skip to content

Commit

Permalink
improvement(k8s): stop bundling kubernetes-dashboard in garden-system
Browse files Browse the repository at this point in the history
Basically it's no longer standard to use it, and more secure and
simpler alternatives now exist (such as Octant, which we will later
add a provider for).
  • Loading branch information
edvald committed Dec 6, 2019
1 parent 17b3e06 commit e3d32e2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 56 deletions.
11 changes: 2 additions & 9 deletions garden-service/src/plugins/kubernetes/local/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import Bluebird from "bluebird"
import { KubernetesConfig, kubernetesConfigBase, k8sContextSchema } from "../config"
import { ConfigureProviderParams } from "../../../types/plugin/provider/configureProvider"
import { joiProviderName, joi } from "../../../config/common"
Expand Down Expand Up @@ -97,11 +96,7 @@ export async function configureProvider(params: ConfigureProviderParams<LocalKub
}

if (config.context === "minikube") {
const initCmds = [
["config", "set", "WantUpdateNotification", "false"],
["addons", "enable", "dashboard"],
]
await Bluebird.map(initCmds, async (cmd) => exec("minikube", cmd))
await exec("minikube", ["config", "set", "WantUpdateNotification", "false"])

if (!config.defaultHostname) {
// use the nip.io service to give a hostname to the instance, if none is explicitly configured
Expand All @@ -117,7 +112,7 @@ export async function configureProvider(params: ConfigureProviderParams<LocalKub

await setMinikubeDockerEnv()
} else if (config.context === "microk8s") {
const addons = ["dns", "dashboard", "registry", "storage"]
const addons = ["dns", "registry", "storage"]

if (config.setupIngressController === "nginx") {
log.debug("Using microk8s's ingress addon")
Expand All @@ -132,8 +127,6 @@ export async function configureProvider(params: ConfigureProviderParams<LocalKub
hostname: "localhost:32000",
namespace,
}
} else {
_systemServices.push("kubernetes-dashboard")
}

if (!config.defaultHostname) {
Expand Down
32 changes: 2 additions & 30 deletions garden-service/src/plugins/kubernetes/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { join } from "path"
import { values, find } from "lodash"
import { values } from "lodash"
import { V1Namespace } from "@kubernetes/client-node"
import semver from "semver"

Expand All @@ -26,7 +26,6 @@ import { PrimitiveMap } from "../../config/common"
import { combineStates } from "../../types/service"
import { KubernetesResource } from "./types"
import { defaultDotIgnoreFiles } from "../../util/fs"
import { HelmServiceStatus } from "./helm/status"
import { LogLevel } from "../../logger/log-node"

const GARDEN_VERSION = getPackageVersion()
Expand Down Expand Up @@ -151,13 +150,7 @@ interface GetSystemServicesStatusParams {
serviceNames: string[]
}

export async function getSystemServiceStatus({
ctx,
sysGarden,
log,
namespace,
serviceNames,
}: GetSystemServicesStatusParams) {
export async function getSystemServiceStatus({ sysGarden, log, serviceNames }: GetSystemServicesStatusParams) {
let dashboardPages: DashboardPage[] = []

const actions = await sysGarden.getActionRouter()
Expand All @@ -168,27 +161,6 @@ export async function getSystemServiceStatus({
})
const state = combineStates(values(serviceStatuses).map((s) => (s && s.state) || "unknown"))

// Add the Kubernetes dashboard to the Garden dashboard
if (serviceNames.includes("kubernetes-dashboard")) {
const defaultHostname = ctx.provider.config.defaultHostname

const dashboardStatus = serviceStatuses["kubernetes-dashboard"] as HelmServiceStatus
const dashboardServiceResource = find(dashboardStatus.detail.remoteResources, (o) => o.kind === "Service")

if (!!dashboardServiceResource) {
const dashboardPort = dashboardServiceResource.spec.ports[0].nodePort

if (!!dashboardPort) {
dashboardPages.push({
title: "Kubernetes",
description: "The standard Kubernetes dashboard for this project",
url: `http://${defaultHostname}:${dashboardPort}/#!/workload?namespace=${namespace}`,
newWindow: true,
})
}
}
}

return {
state,
serviceStatuses,
Expand Down

This file was deleted.

0 comments on commit e3d32e2

Please sign in to comment.