-
Notifications
You must be signed in to change notification settings - Fork 0
calico: upstream pr preparation #7
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
base: develop
Are you sure you want to change the base?
Changes from all commits
eb808ca
073e26f
b818e49
1e25811
36b7501
6c429ae
602ebb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,12 @@ RUN arch="$(uname -m | sed -e s/x86_64/amd64/ -e s/aarch64/arm64/)" && \ | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| gettext-base \ | ||
| moreutils \ | ||
| socat | ||
| socat ipset wget | ||
| ADD Dockerfile.d/etc_udev_rules.d_90-flannel.rules /etc/udev/rules.d/90-flannel.rules | ||
| ADD Dockerfile.d/etc_udev_rules.d_95-calico.rules /etc/udev/rules.d/95-calico.rules | ||
| ADD Dockerfile.d/u7s-entrypoint.sh / | ||
| # Calico | ||
| ENV FELIX_IGNORELOOSERPF=true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is only passed to the entrypoint script, so probably not effective |
||
| RUN wget https://github.com/projectcalico/calico/releases/download/v3.30.5/calicoctl-linux-amd64 -O /tmp/calicoctl && \ | ||
| chmod +x /tmp/calicoctl && mv /tmp/calicoctl /usr/local/bin | ||
| ENTRYPOINT ["/u7s-entrypoint.sh", "/usr/local/bin/entrypoint", "/sbin/init"] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but we would need to name it something else so it's not specific to flannel. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| SUBSYSTEM=="net", ACTION=="add|change|move", ENV{INTERFACE}=="vxlan.calico", RUN+="/usr/sbin/ethtool -K vxlan.calico tx-checksum-ip-generic off" |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this need to be a daemonset?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also had it as a COPY to the container via a udev rules files, but I don't think it took. At least whatever state changes the initial calico install triggered might have undone it. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| apiVersion: apps/v1 | ||
| kind: DaemonSet | ||
| metadata: | ||
| name: calico-checksum-fix | ||
| namespace: kube-system | ||
| labels: | ||
| k8s-app: calico-checksum-fix | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| name: calico-checksum-fix | ||
| template: | ||
| metadata: | ||
| labels: | ||
| name: calico-checksum-fix | ||
| spec: | ||
| hostNetwork: true | ||
| hostPID: true | ||
| securityContext: | ||
| runAsUser: 0 | ||
| initContainers: | ||
| - name: fix-checksum | ||
| image: ghcr.io/converged-computing/usernetes:alpine | ||
| # image: alpine:latest | ||
| command: ["/bin/sh", "-c"] | ||
| args: | ||
| - | | ||
| # nsenter -t 1 enters the init process's namespace (of the host) | ||
| # check if the interface exists before running ethtool | ||
| if [ -d /sys/class/net/vxlan.calico ]; then | ||
| echo "Applying ethtool fix to vxlan.calico..." | ||
| nsenter -t 1 -n -u -i -m -- ethtool -K vxlan.calico tx-checksum-ip-generic off | ||
| else | ||
| echo "vxlan.calico interface not found, skipping." | ||
| fi | ||
| iptables -I INPUT -p udp --dport 8472 -j ACCEPT | ||
| sysctl -w net.ipv4.conf.all.rp_filter=1 | ||
| sysctl -w net.ipv4.conf.default.rp_filter=1 | ||
| sysctl -w net.ipv4.conf.eth0.rp_filter=1 | ||
| sysctl -w net.ipv4.conf.vxlan/calico.rp_filter=1 | ||
| securityContext: | ||
| privileged: true | ||
| containers: | ||
| - name: pause | ||
| # image: registry.k8s.io/pause:3.9 | ||
| image: ghcr.io/converged-computing/usernetes:pause | ||
| terminationGracePeriodSeconds: 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Install standard Calico | ||
| CALICO_VERSION="v3.31" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. version should be consolidated in https://github.com/rootless-containers/usernetes/blob/9658658396ec51fe74a8e9f2bc0b62792a7223e5/Dockerfile#L1-L4 |
||
| CALICO_FILE="calico.yaml" | ||
| wget https://raw.githubusercontent.com/projectcalico/calico/refs/heads/release-v3.31/manifests/calico.yaml -O $CALICO_FILE | ||
|
|
||
| # backend to vxlan | ||
| yq eval-all -i '(select(.kind == "ConfigMap" and .metadata.name == "calico-config").data.calico_backend) = "vxlan"' $CALICO_FILE | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use helm with values.yaml ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No we tried for weeks to get helm working - it was too complex. If you want to try and are successful we can do some testing of what you find. |
||
|
|
||
| # IPIP and VXLAN | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs explanation |
||
| yq eval-all -i '(select(.kind == "DaemonSet" and .metadata.name == "calico-node").spec.template.spec.containers[0].env[] | select(.name == "CALICO_IPV4POOL_IPIP").value) = "Never"' $CALICO_FILE | ||
| yq eval-all -i '(select(.kind == "DaemonSet" and .metadata.name == "calico-node").spec.template.spec.containers[0].env[] | select(.name == "CALICO_IPV4POOL_VXLAN").value) = "CrossSubnet"' $CALICO_FILE | ||
| yq eval-all -i '(select(.kind == "DaemonSet" and .metadata.name == "calico-node").spec.template.spec.containers[0].env[] | select(.name == "CALICO_IPV6POOL_VXLAN").value) = "CrossSubnet"' $CALICO_FILE | ||
|
|
||
| # FELIX for rootless | ||
| yq eval-all -i 'select(.kind == "DaemonSet" and .metadata.name == "calico-node").spec.template.spec.containers[0].env += {"name": "FELIX_IGNORELOOSERPF", "value": "true"}' $CALICO_FILE | ||
| yq eval-all -i 'select(.kind == "DaemonSet" and .metadata.name == "calico-node").spec.template.spec.containers[0].env += {"name": "FELIX_VXLANPORT", "value": "8472"}' $CALICO_FILE | ||
| yq eval-all -i 'select(.kind == "DaemonSet" and .metadata.name == "calico-node").spec.template.spec.containers[0].env += {"name": "FELIX_EXTERNALNODESCIDRLIST", "value": "10.100.0.0/16"}' $CALICO_FILE | ||
|
|
||
| # health probes (Remove bird-ready and bird-live) | ||
| yq eval-all -i '(select(.kind == "DaemonSet" and .metadata.name == "calico-node").spec.template.spec.containers[0].livenessProbe.exec.command) = ["/bin/calico-node", "-felix-live"]' $CALICO_FILE | ||
| yq eval-all -i '(select(.kind == "DaemonSet" and .metadata.name == "calico-node").spec.template.spec.containers[0].readinessProbe.exec.command) = ["/bin/calico-node", "-felix-ready"]' $CALICO_FILE | ||
|
|
||
| # install components with our rootless version | ||
| kubectl apply -f ${CALICO_FILE} | ||
| echo "Done. Final file is $CALICO_FILE" | ||
|
|
||
| # Give a small break to settle - we need calico.vxlan to be created | ||
| sleep 10 | ||
|
|
||
| # This must be removed or the address will be reset | ||
| kubectl set env daemonset/calico-node IP- -n kube-system | ||
|
|
||
| # Allow pods to recreate | ||
| echo "Recreating calico pods..." | ||
| sleep 10 | ||
|
|
||
| # https://youtu.be/noriIzBKYRk?si=mlOC27ntvSEDw_VM&t=299 | ||
| # These commands need to be done bringing up node | ||
| # iptables -I INPUT -p udp --dport 8472 -j ACCEPT | ||
| # sysctl -w net.ipv4.conf.all.rp_filter=2 | ||
| # sysctl -w net.ipv4.conf.default.rp_filter=2 | ||
| # sysctl -w net.ipv4.conf.eth0.rp_filter=2 | ||
| # sysctl -w "net.ipv4.conf.vxlan/calico.rp_filter=2" | ||
|
|
||
| # This needs to be done after daemonset is patched | ||
| # Note that the calico-node has a warning after this, but it won't work if we don't do it | ||
| for node in $(kubectl get nodes -o name); do | ||
| host_ip="$(kubectl get "${node}" -o jsonpath='{.metadata.labels.usernetes/host-ip}')" | ||
| nodename=$(cut -d / -f 2 <<< $node) | ||
| calicoctl --allow-version-mismatch patch node ${nodename} --patch='{"spec": {"bgp":{"ipv4Address": "'"$host_ip"'"}}}' | ||
| done | ||
|
|
||
| # applies ethtool -K vxlan.calico tx-checksum-ip-generic off | ||
| # check with: bridge fdb show dev vxlan.calico should have node address NOT 10.x address | ||
| kubectl apply --server-side -f /usernetes/Makefile.d/calico/calico-ethtool.yaml | ||
|
|
||
| # These should be run after calico installed | ||
| # 1. make sync-external-ip and make install-calico | ||
| # the second has a daemonset to apply these commands | ||
| # ethtool -K vxlan.calico tx-checksum-ip-generic off | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,9 @@ script_dir="$(dirname "$0")" | |
| detect_engine="${script_dir}"/detect-container-engine.sh | ||
| : "${CONTAINER_ENGINE:=$("${detect_engine}" CONTAINER_ENGINE)}" | ||
| : "${CONTAINER_ENGINE_TYPE:=$("${detect_engine}" CONTAINER_ENGINE_TYPE)}" | ||
| : "${QUICK:=0}" | ||
|
|
||
| # Set to 1 since we will do calico by default | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default should not change yet |
||
| : "${QUICK:=1}" | ||
| : "${BUSYBOX_IMAGE:=docker.io/library/busybox:latest}" | ||
|
|
||
| if [ -z "${CONTAINER_ENGINE}" ] || [ -z "${CONTAINER_ENGINE_TYPE}" ]; then | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,4 +16,6 @@ for node in $(kubectl get nodes -o name); do | |
| if echo "${taints}" | grep -q node.cloudprovider.kubernetes.io/uninitialized; then | ||
| kubectl taint nodes "${node}" node.cloudprovider.kubernetes.io/uninitialized- | ||
| fi | ||
| nodename=$(cut -d / -f 2 <<< $node) | ||
| calicoctl --allow-version-mismatch patch node ${nodename} --patch='{"spec": {"bgp":{"ipv4Address": "'"$host_ip"'"}}}' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs explanation, and has to be skipped in non-calico setup There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does bgp matter here? |
||
| done | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ but Usernetes (Gen 2) supports creating a cluster with multiple hosts. | |
| - CRI: containerd | ||
| - OCI: runc | ||
| - CNI: Flannel | ||
| - CNI: Calico | ||
|
|
||
| ## Requirements | ||
|
|
||
|
|
@@ -72,7 +73,8 @@ EOF | |
| sudo systemctl restart systemd-modules-load.service | ||
| ``` | ||
|
|
||
| - sysctl: | ||
| - sysctl (should not be required for calico, but needs testing) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doubtful
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate? |
||
|
|
||
| ``` | ||
| sudo tee /etc/sysctl.d/99-usernetes.conf <<EOF >/dev/null | ||
| net.ipv4.conf.default.rp_filter = 2 | ||
|
|
@@ -110,6 +112,8 @@ See `make help`. | |
| make up | ||
| make kubeadm-init | ||
| make install-flannel | ||
| # or | ||
| make install-calico | ||
|
|
||
| # Enable kubectl | ||
| make kubeconfig | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,14 +5,24 @@ set -euo pipefail | |
| # These are variables we likely will change | ||
| # LC only supplies podman | ||
| USERNETES_CONTAINER_TECH=${1:-"podman"} | ||
| USERNETES_TEMPLATE_PATH=/usr/workspace/usernetes/usernetes-06-26-2025 | ||
| USERNETES_TEMPLATE_PATH=/usr/workspace/usernetes/usernetes-calico | ||
|
|
||
| # We will copy join command here | ||
| shared_join_command_dir="/usr/workspace/usernetes" | ||
|
|
||
| # The user needs to run the setup script | ||
| USERNAME=$(whoami) | ||
|
|
||
| # Logging functions for consistency (like Akihiro!) | ||
| log() { | ||
| echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - $1" | ||
| } | ||
|
|
||
| error_exit() { | ||
| echo "$(date '+%Y-%m-%d %H:%M:%S') - ERROR - $1" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| # This is way a lot for just deriving home, but I'm not convinced it will always | ||
| # be defined in the environment | ||
| if [[ -z "${HOME:-}" || ! -d "${HOME}" ]]; then | ||
|
|
@@ -37,16 +47,6 @@ which podman-compose | |
| # We don't want to use /var because that is a memory based fs | ||
| export TMPDIR="/tmp/${USERNAME}" | ||
|
|
||
| # Logging functions for consistency (like Akihiro!) | ||
| log() { | ||
| echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - $1" | ||
| } | ||
|
|
||
| error_exit() { | ||
| echo "$(date '+%Y-%m-%d %H:%M:%S') - ERROR - $1" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| install_kubectl() { | ||
| if ! command -v kubectl > /dev/null; then | ||
| log "Installing kubectl..." | ||
|
|
@@ -60,7 +60,20 @@ install_kubectl() { | |
| command -v kubectl > /dev/null || error_exit "kubectl not found after installation attempt." | ||
| } | ||
|
|
||
|
|
||
| install_yq() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be consolidated to https://github.com/rootless-containers/usernetes/blob/master/Dockerfile |
||
| if ! command -v yq > /dev/null; then | ||
| log "Installing yq..." | ||
| YQ_VERSION=v4.2.0 | ||
| YQ_PLATFORM=linux_amd64 | ||
| wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_${YQ_PLATFORM}.tar.gz -O - | tar xz | ||
| chmod +x ./yq_${YQ_PLATFORM} | ||
| mv ./yq_${YQ_PLATFORM} "${LOCAL_BIN_DIR}/yq" | ||
| log " yq installed to ${LOCAL_BIN_DIR}/yq" | ||
| else | ||
| log " yq found at $(command -v yq)" | ||
| fi | ||
| command -v yq > /dev/null || error_exit "yq not found after installation attempt." | ||
| } | ||
|
|
||
| # Pre-flight Checks & Setup | ||
| log "🎬 Starting Usernetes Control Plane Setup" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wget and curl should not be mixed up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code comment should explain why ipset is needed