Skip to content

Instantly share code, notes, and snippets.

@usrbinkat
Last active March 24, 2024 02:02
Show Gist options
  • Save usrbinkat/44695bf8cb80cd365edaafe36eebb23b to your computer and use it in GitHub Desktop.
Save usrbinkat/44695bf8cb80cd365edaafe36eebb23b to your computer and use it in GitHub Desktop.
Cilium Strict + Multus multihome cni investigation

Cilium + Multus CNI

# ChatGPT authored python script to compare 2 helm values files as dicts and isolate the diffs
import yaml
# Convert the YAML content into Python dictionaries for easier comparison
def convert_yaml_to_dict(yaml_content):
return yaml.safe_load(yaml_content)
default_values_dict = convert_yaml_to_dict(default_values_content)
custom_values_dict = convert_yaml_to_dict(custom_values_content)
# Function to recursively compare two dictionaries and return the differences
def compare_dicts(dict1, dict2, path=""):
differences = {}
# Check all keys in the first dict
for key in dict1:
if key not in dict2:
differences[f"{path}{key}"] = {"default": dict1[key], "custom": None}
elif type(dict1[key]) is dict:
if type(dict2[key]) is not dict:
differences[f"{path}{key}"] = {"default": dict1[key], "custom": dict2[key]}
else:
deeper_diff = compare_dicts(dict1[key], dict2[key], f"{path}{key}.")
if deeper_diff:
differences.update(deeper_diff)
elif dict1[key] != dict2[key]:
differences[f"{path}{key}"] = {"default": dict1[key], "custom": dict2[key]}
# Check all keys in the second dict to find missing ones in the first dict
for key in dict2:
if key not in dict1:
differences[f"{path}{key}"] = {"default": None, "custom": dict2[key]}
return differences
# Compare the two dictionaries to find differences
differences = compare_dicts(default_values_dict, custom_values_dict)
# Display the differences found
differences
{
 'k8sServiceHost': {'default': '', 'custom': '10.83.86.10'},
 'k8sServicePort': {'default': '', 'custom': '6443'},
 'bgpControlPlane.enabled': {'default': False, 'custom': True},
 'cni.exclusive': {'default': True, 'custom': False},
 'envoyConfig.enabled': {'default': False, 'custom': True},
 'ingressController.enabled': {'default': False, 'custom': True},
 'ingressController.loadbalancerMode': {'default': 'dedicated',
  'custom': 'shared'},
 'gatewayAPI.enabled': {'default': False, 'custom': True},
 'encryption.enabled': {'default': False, 'custom': True},
 'encryption.type': {'default': 'ipsec', 'custom': 'wireguard'},
 'encryption.nodeEncryption': {'default': False, 'custom': True},
 'hubble.metrics.enabled': {'default': None,
  'custom': ['dns:query;ignoreAAAA', 'drop', 'tcp', 'flow', 'icmp', 'http']},
 'hubble.metrics.enableOpenMetrics': {'default': False, 'custom': True},
 'hubble.metrics.serviceMonitor.enabled': {'default': False, 'custom': True},
 'hubble.metrics.dashboards.enabled': {'default': False, 'custom': True},
 'hubble.metrics.dashboards.namespace': {'default': None, 'custom': 'grafana'},
 'hubble.tls.auto.method': {'default': 'helm', 'custom': 'cronJob'},
 'hubble.tls.auto.certManagerIssuerRef.group': {'default': None,
  'custom': 'cert-manager.io'},
 'hubble.tls.auto.certManagerIssuerRef.kind': {'default': None,
  'custom': 'ClusterIssuer'},
 'hubble.tls.auto.certManagerIssuerRef.name': {'default': None,
  'custom': 'selfsigned'},
 'hubble.relay.enabled': {'default': False, 'custom': True},
 'hubble.relay.prometheus.enabled': {'default': False, 'custom': True},
 'hubble.relay.prometheus.serviceMonitor.enabled': {'default': False,
  'custom': True},
 'hubble.ui.enabled': {'default': False, 'custom': True},
 'ipv4NativeRoutingCIDR': {'default': '', 'custom': '10.83.86.0/24'},
 'prometheus.enabled': {'default': False, 'custom': True},
 'prometheus.serviceMonitor.enabled': {'default': False, 'custom': True},
 'prometheus.serviceMonitor.trustCRDsExist': {'default': False,
  'custom': True},
 'dashboards.enabled': {'default': False, 'custom': True},
 'dashboards.namespace': {'default': None, 'custom': 'grafana'},
 'operator.prometheus.serviceMonitor.enabled': {'default': False,
  'custom': True},
 'operator.dashboards.enabled': {'default': False, 'custom': True},
 'operator.dashboards.namespace': {'default': None, 'custom': 'grafana'},
 'clustermesh.apiserver.tls.auto.method': {'default': 'helm',
  'custom': 'certmanager'},
 'clustermesh.apiserver.tls.auto.certManagerIssuerRef.group': {'default': None,
  'custom': 'cert-manager.io'},
 'clustermesh.apiserver.tls.auto.certManagerIssuerRef.kind': {'default': None,
  'custom': 'ClusterIssuer'},
 'clustermesh.apiserver.tls.auto.certManagerIssuerRef.name': {'default': None,
  'custom': 'selfsigned'},
 'enableCnpStatusUpdates': {'default': None, 'custom': False},
 'enableK8sEventHandover': {'default': None, 'custom': False},
 'kubeProxyReplacement': {'default': None, 'custom': 'true'}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment