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

Add helm-based installation for hubble integration #778

Merged
merged 3 commits into from
Apr 8, 2022

Conversation

aanm
Copy link
Member

@aanm aanm commented Apr 5, 2022

Besides switched to a helm-based installation. This PR also enables TLS for hubble. Previously, cilium-cli had the TLS disabled for hubble-ui

@aanm aanm requested a review from a team April 5, 2022 14:12
@aanm aanm requested a review from a team as a code owner April 5, 2022 14:12
@aanm aanm requested review from a team, nebril and michi-covalent April 5, 2022 14:12
@aanm aanm temporarily deployed to ci April 5, 2022 14:12 Inactive
@aanm aanm force-pushed the pr/helm-based-installation-hubble branch from b15ae23 to 04427b2 Compare April 5, 2022 15:10
@aanm aanm temporarily deployed to ci April 5, 2022 15:10 Inactive
@aanm
Copy link
Member Author

aanm commented Apr 5, 2022

putting in draft since the CI is failing a lot

@aanm aanm marked this pull request as draft April 5, 2022 15:31
@aanm aanm force-pushed the pr/helm-based-installation-hubble branch from 04427b2 to 04d400d Compare April 5, 2022 22:08
@aanm aanm temporarily deployed to ci April 5, 2022 22:08 Inactive
@aanm aanm force-pushed the pr/helm-based-installation-hubble branch from 04d400d to bbd80de Compare April 5, 2022 22:21
@aanm aanm temporarily deployed to ci April 5, 2022 22:21 Inactive
aanm added 2 commits April 6, 2022 00:27
These changes are needed for the upcoming changes that adds helm support
to the remaining CLI options.

Signed-off-by: André Martins <[email protected]>
Since in YAML dots are used to represent a path, when converting helm
values into a string representation YAML keys that had dots were wrongly
represented. This commit escapes the dots to correctly represent the
helm keys.

Signed-off-by: André Martins <[email protected]>
@aanm aanm force-pushed the pr/helm-based-installation-hubble branch from bbd80de to c358bde Compare April 6, 2022 00:03
@aanm aanm temporarily deployed to ci April 6, 2022 00:03 Inactive
@aanm aanm marked this pull request as ready for review April 6, 2022 03:06
@michi-covalent
Copy link
Contributor

tested with gke. enabling hubble is working, but i'm seeing issues with cilium hubble port-forward and hubble-ui 🤔

✅ install cilium

% ./cilium install
🔮 Auto-detected Kubernetes kind: GKE
ℹ️  using Cilium version "v1.11.3"
🔮 Auto-detected cluster name: gke-cilium-dev-us-west2-a-michi-23762
🔮 Auto-detected IPAM mode: kubernetes
🔮 Auto-detected datapath mode: gke
✅ Detected GKE native routing CIDR: 10.32.0.0/14
ℹ️  helm template --namespace kube-system cilium cilium/cilium --version 1.11.3 --set cluster.id=0,cluster.name=gke-cilium-dev-us-west2-a-michi-23762,cni.binPath=/home/kubernetes/bin,encryption.nodeEncryption=false,gke.disableDefaultSnat=true,gke.enabled=true,ipam.mode=kubernetes,ipv4NativeRoutingCIDR=10.32.0.0/14,kubeProxyReplacement=disabled,nodeinit.enabled=true,nodeinit.reconfigureKubelet=true,nodeinit.removeCbrBridge=true,operator.replicas=1,serviceAccounts.cilium.name=cilium,serviceAccounts.operator.name=cilium-operator
🚀 Creating Resource quotas...
🔑 Created CA in secret cilium-ca
🔑 Generating certificates for Hubble...
🚀 Creating Service accounts...
🚀 Creating Cluster roles...
🚀 Creating ConfigMap for Cilium version 1.11.3...
🚀 Creating GKE Node Init DaemonSet...
🚀 Creating Agent DaemonSet...
🚀 Creating Operator Deployment...
⌛ Waiting for Cilium to be installed and ready...
♻️  Restarting unmanaged pods...
♻️  Restarted unmanaged pod kube-system/event-exporter-gke-5479fd58c8-vnmw4
♻️  Restarted unmanaged pod kube-system/konnectivity-agent-6db7c55769-hn7f5
♻️  Restarted unmanaged pod kube-system/konnectivity-agent-autoscaler-6849fff748-hstzp
♻️  Restarted unmanaged pod kube-system/kube-dns-697dc8fc8b-rbvhg
♻️  Restarted unmanaged pod kube-system/kube-dns-autoscaler-844c9d9448-cbqbr
♻️  Restarted unmanaged pod kube-system/l7-default-backend-69fb9fd9f9-bwrq6
♻️  Restarted unmanaged pod kube-system/metrics-server-v0.4.5-56fcb96597-l5ghr
✅ Cilium was successfully installed! Run 'cilium status' to view installation health

✅ enable hubble with ui

 % ./cilium hubble enable --ui
🔑 Found CA in secret cilium-ca
ℹ️  helm template --namespace kube-system cilium cilium/cilium --version 1.11.3 --set cluster.id=0,cluster.name=gke-cilium-dev-us-west2-a-michi-23762,cni.binPath=/home/kubernetes/bin,encryption.nodeEncryption=false,gke.disableDefaultSnat=true,gke.enabled=true,hubble.enabled=true,hubble.listenAddress=:4244,hubble.relay.enabled=true,hubble.relay.tls.server.enabled=true,hubble.socketPath=/var/run/cilium/hubble.sock,hubble.tls.enabled=true,hubble.ui.enabled=true,hubble.ui.securityContext.enabled=false,ipam.mode=kubernetes,ipv4NativeRoutingCIDR=10.32.0.0/14,kubeProxyReplacement=disabled,nodeinit.enabled=true,nodeinit.reconfigureKubelet=true,nodeinit.removeCbrBridge=true,operator.replicas=1,serviceAccounts.cilium.name=cilium,serviceAccounts.operator.name=cilium-operator
✨ Patching ConfigMap cilium-config to enable Hubble...
🚀 Creating ConfigMap for Cilium version 1.11.3...
♻️  Restarted Cilium pods
⌛ Waiting for Cilium to become ready before deploying other Hubble component(s)...
✨ Generating certificates...
🔑 Generating certificates for Relay...
✨ Deploying Relay...
✨ Generating certificates...
🔑 Generating certificates for UI...
✨ Deploying Hubble UI and Hubble UI Backend...
⌛ Waiting for Hubble to be installed...
✅ Hubble was successfully enabled!

⁉️ port-forward command seems to get stuck:

% ./cilium hubble port-forward
ℹ️  helm template --namespace kube-system cilium cilium/cilium --version 1.11.3 --set cluster.id=0,cluster.name=gke-cilium-dev-us-west2-a-michi-23762,cni.binPath=/home/kubernetes/bin,encryption.nodeEncryption=false,gke.disableDefaultSnat=true,gke.enabled=true,hubble.enabled=true,hubble.listenAddress=:4244,hubble.relay.enabled=true,hubble.relay.tls.server.enabled=true,hubble.socketPath=/var/run/cilium/hubble.sock,hubble.tls.enabled=true,hubble.ui.enabled=true,hubble.ui.securityContext.enabled=false,ipam.mode=kubernetes,ipv4NativeRoutingCIDR=10.32.0.0/14,kubeProxyReplacement=disabled,nodeinit.enabled=true,nodeinit.reconfigureKubelet=true,nodeinit.removeCbrBridge=true,operator.replicas=1,serviceAccounts.cilium.name=cilium,serviceAccounts.operator.name=cilium-operator
...

⁉️ hubble-ui is not loading

Screen Shot 2022-04-06 at 5 22 40 PM

i see errors like these in hubble-ui backend container log:

level=error msg="flow error: EOF\n" subsys=ui-backend
level=error msg="fetching hubble flows: connecting to hubble-relay (attempt #1) failed: rpc error: code = Canceled desc = context canceled\n" subsys=ui-backend
...

@aanm aanm force-pushed the pr/helm-based-installation-hubble branch from c358bde to 0620c5f Compare April 7, 2022 14:39
@aanm aanm temporarily deployed to ci April 7, 2022 14:41 Inactive
@aanm aanm force-pushed the pr/helm-based-installation-hubble branch from 0620c5f to 2c565e4 Compare April 7, 2022 16:08
@aanm aanm temporarily deployed to ci April 7, 2022 16:08 Inactive
Copy link
Contributor

@michi-covalent michi-covalent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested again with the updated branch, and everything worked.

cilium install
cilium hubble enable
cilium hubble port-forward and then hubble observe.
cilium hubble ui and checked kube-system namespace shows flows.

Copy link
Member

@rolinh rolinh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the changes and it is functional. However, I have some concerns, a low one, a medium one and a high one :)

  1. (low) Why is helm template ... printed out when running cilium hubble port-forward? I wouldn't expect this command to be printed out for commands that I don't expect to change anytning in the cluster.
  2. (medium) We now print the b64 encoded TLS keypair when installing. Could we somehow hide or truncate it before printing?
% cilium hubble enable --ui
🔑 Found CA in secret cilium-ca
ℹ️  helm template --namespace kube-system cilium cilium/cilium --version 1.11.3 --set cluster.id=0,cluster.name=kind-kind,encryption.nodeEncryption=false,hubble.enabled=true,hubble.listenAddress=:4244,hubble.relay.enabled=true,hubble.relay.tls.server.enabled=true,hubble.socketPath=/var/run/cilium/hubble.sock,hubble.tls.ca.cert=LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNGRENDQWJxZ0F3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RmFreStMNmttcW14S3ZVc25jYzhtdXRxRmVaNmlrZ1ExQWwxdlZXbEFvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFTzhTMlBsTTRxMHFYUlBiazdNcDlEblZPTnhVcWx4L3M3VVdUVERlTzBQQnNqdjZDa25JUgpjZCtkTGVtaFI4bEs2ZGRoQ0FHenh2LzF0SUpuWEVzZkJ3PT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=,hubble.tls.enabled=true,hubble.ui.enabled=true,hubble.ui.securityContext.enabled=false,ipam.mode=kubernetes,kubeProxyReplacement=disabled,operator.replicas=1,serviceAccounts.cilium.name=cilium,serviceAccounts.operator.name=cilium-operator,tunnel=vxlan
✨ Patching ConfigMap cilium-config to enable Hubble...
🚀 Creating ConfigMap for Cilium version 1.11.3...
♻️  Restarted Cilium pods
⌛ Waiting for Cilium to become ready before deploying other Hubble component(s)...
✨ Generating certificates...
🔑 Generating certificates for Relay...
✨ Deploying Relay...
✨ Generating certificates...
🔑 Generating certificates for UI...
✨ Deploying Hubble UI and Hubble UI Backend...
⌛ Waiting for Hubble to be installed...
✅ Hubble was successfully enabled!
  1. (high) I think that enabling TLS for the Relay service should be done as part of another PR as it affects the user experience. I want to make it clear that overall I think we should enable TLS (or even mTLS) by default for the Relay service. However, doing so without further consideration breaks current user's workflows and would require us to also update Cilium documentation. Indeed, when a user now runs cilium hubble port-forward and then run a Hubble CLI command such as hubble status or hubble observe, they are greeted with the following message (after some time elapsed):
% hubble status
failed to connect to 'localhost:4245': context deadline exceeded: connection closed before server preface received

This is because the Hubble CLI needs to be told to use TLS, e.g. by providing the --tls flag. However, in itself, this is insufficient as users also need to either pass the scary --tls-allow-insecure OR import the CA and validate via server name (which is rather painful to do.
I think that ultimately, we should update the Hubble CLI so that it reads the kubeconfig and does the right thing for things to work out of the box (without even requiring cilium hubble port-forward). Could we then create issues for relevant work to enable TLS by default and drop this change from this PR?

hubble/hubble.go Outdated Show resolved Hide resolved
@aanm aanm force-pushed the pr/helm-based-installation-hubble branch from 2c565e4 to 1e1eac3 Compare April 7, 2022 19:31
@aanm aanm temporarily deployed to ci April 7, 2022 19:31 Inactive
By storing helm-based config values into Cilium's ConfigMap we are able
to generate hubble deployment files by reading those values. Once the
manifests are generated, the new helm flags used to enable hubble and/or
hubble-ui and/or hubble-relay will also be store in Cilium's ConfigMap.

Similarly to 'hubble enable', 'hubble disable' command also stores the
helm-based config values into Cilium's ConfigMap.

Signed-off-by: André Martins <[email protected]>
@aanm aanm force-pushed the pr/helm-based-installation-hubble branch from 1e1eac3 to ebd12e3 Compare April 7, 2022 19:42
@aanm aanm temporarily deployed to ci April 7, 2022 19:42 Inactive
@aanm aanm requested a review from rolinh April 7, 2022 20:30
@michi-covalent
Copy link
Contributor

andre claims that robin gave a +1 offline. merging.

@michi-covalent michi-covalent merged commit 269a984 into master Apr 8, 2022
@michi-covalent michi-covalent deleted the pr/helm-based-installation-hubble branch April 8, 2022 20:41
@qmonnet
Copy link
Member

qmonnet commented Apr 19, 2022

@aanm Have you tested this change with Kind, by any chance? Trying with the latest release, I'm getting the following error:

$ cilium hubble enable 
🔑 Found CA in secret cilium-ca

Error: Unable to enable Hubble:  unable to retrieve helm values secret kube-system/cilium-cli-helm-values: secrets "cilium-cli-helm-values" not found

I bisected to commit 269a984, but can't tell for sure whether this is a bug or if I'm doing something wrong.

[EDIT] Sorted this out offline. This is because I installed Cilium with Helm, instead of using cilium install as I should have. Follow-up: We'll have to update the docs that explain how to install Cilium on Kind (currently recommending to use Helm).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants