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

hubble: Make UI version configurable #645

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
HubbleUIServiceAccountName = "hubble-ui"
HubbleUIConfigMapName = "hubble-ui-envoy"
HubbleUIDeploymentName = "hubble-ui"
HubbleUIImage = "quay.io/cilium/hubble-ui"
HubbleUIBackendImage = "quay.io/cilium/hubble-ui-backend"

ClusterMeshDeploymentName = "clustermesh-apiserver"
ClusterMeshServiceAccountName = "clustermesh-apiserver"
Expand All @@ -66,8 +68,9 @@ const (
ConnectivityCheckAlpineCurlImage = "quay.io/cilium/alpine-curl:v1.4.0@sha256:2550c747831ff575f2147149b088ea981c06f9b6bcd188756d1b82cc10997956"
ConnectivityCheckJSONMockImage = "quay.io/cilium/json-mock:v1.3.0@sha256:2729064827fa9dbfface8d3df424feb6c792a0ba07117b844349635c93c06d2b"

ConfigMapName = "cilium-config"
Version = "v1.10.5"
ConfigMapName = "cilium-config"
Version = "v1.10.5"
HubbleUIVersion = "v0.8.3"

TunnelType = "vxlan"

Expand Down
16 changes: 12 additions & 4 deletions hubble/hubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ type Parameters struct {
PortForward int
CreateCA bool
UI bool
UIImage string
UIBackendImage string
UIVersion string
UIPortForward int
Writer io.Writer
Context string // Only for 'kubectl' pass-through commands
Expand All @@ -88,10 +91,15 @@ func (p *Parameters) Log(format string, a ...interface{}) {
}

func (p *Parameters) validateParams() error {
if p.RelayImage != defaults.RelayImage {
return nil
} else if !utils.CheckVersion(p.RelayVersion) && p.RelayVersion != "" {
return fmt.Errorf("invalid syntax %q for image tag", p.RelayVersion)
if p.RelayImage == defaults.RelayImage {
if !utils.CheckVersion(p.RelayVersion) && p.RelayVersion != "" {
return fmt.Errorf("invalid syntax %q for image tag", p.RelayVersion)
}
}
if p.UIImage == defaults.HubbleUIImage || p.UIBackendImage == defaults.HubbleUIBackendImage {
if !utils.CheckVersion(p.UIVersion) && p.UIVersion != "" {
return fmt.Errorf("invalid syntax %q for image tag", p.UIVersion)
}
}
return nil
}
Expand Down
14 changes: 11 additions & 3 deletions hubble/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (k *K8sHubble) generateHubbleUIDeployment() *appsv1.Deployment {
Containers: []corev1.Container{
{
Name: "frontend",
Image: "quay.io/cilium/hubble-ui:v0.8.3@sha256:018ed122968de658d8874e2982fa6b3a8ae64b43d2356c05f977004176a89310",
tklauser marked this conversation as resolved.
Show resolved Hide resolved
Image: k.uiImage(),
ImagePullPolicy: corev1.PullIfNotPresent,
Ports: []corev1.ContainerPort{
{
Expand All @@ -199,7 +199,7 @@ func (k *K8sHubble) generateHubbleUIDeployment() *appsv1.Deployment {
},
{
Name: "backend",
Image: "quay.io/cilium/hubble-ui-backend:v0.8.3@sha256:13a16ed3ae9749682c817d3b834b2f2de901da6fb41de7753d7dce16650982b3",
Image: k.uiBackendImage(),
ImagePullPolicy: corev1.PullIfNotPresent,
Env: []corev1.EnvVar{
{Name: "EVENTS_SERVER_PORT", Value: "8090"},
Expand Down Expand Up @@ -256,6 +256,14 @@ func (k *K8sHubble) generateHubbleUIDeployment() *appsv1.Deployment {
return d
}

func (k *K8sHubble) uiImage() string {
return utils.BuildImagePath(k.params.UIImage, defaults.HubbleUIImage, k.params.UIVersion, defaults.HubbleUIVersion)
}

func (k *K8sHubble) uiBackendImage() string {
return utils.BuildImagePath(k.params.UIBackendImage, defaults.HubbleUIBackendImage, k.params.UIVersion, defaults.HubbleUIVersion)
}

func (k *K8sHubble) disableUI(ctx context.Context) error {
k.Log("🔥 Deleting Hubble UI...")
k.client.DeleteService(ctx, k.params.Namespace, defaults.HubbleUIServiceName, metav1.DeleteOptions{})
Expand All @@ -275,7 +283,7 @@ func (k *K8sHubble) enableUI(ctx context.Context) error {
return nil
}

k.Log("✨ Deploying Hubble UI...")
k.Log("✨ Deploying Hubble UI from %s and Hubble UI Backend from %s...", k.uiImage(), k.uiBackendImage())
if _, err := k.client.CreateConfigMap(ctx, k.params.Namespace, k.generateHubbleUIConfigMap(), metav1.CreateOptions{}); err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions internal/cli/cmd/hubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func newCmdHubbleEnable() *cobra.Command {
cmd.Flags().StringVar(&params.RelayVersion, "relay-version", "", "Version of Relay to deploy")
cmd.Flags().StringVar(&params.RelayServiceType, "relay-service-type", "ClusterIP", "Type of Kubernetes service to expose Hubble Relay")
cmd.Flags().BoolVar(&params.UI, "ui", false, "Enable Hubble UI")
cmd.Flags().StringVar(&params.UIImage, "ui-image", "", "Image path to use for UI")
cmd.Flags().StringVar(&params.UIBackendImage, "ui-backend-image", "", "Image path to use for UI backend")
cmd.Flags().StringVar(&params.UIVersion, "ui-version", "", "Version of UI to deploy")
cmd.Flags().BoolVar(&params.CreateCA, "create-ca", true, "Automatically create CA if needed")
cmd.Flags().StringVar(&contextName, "context", "", "Kubernetes configuration context")
cmd.Flags().BoolVar(&params.Wait, "wait", true, "Wait for status to report success (no errors)")
Expand Down