Skip to content

Instantly share code, notes, and snippets.

View ormergi's full-sized avatar

Or Mergi ormergi

  • Red Hat
View GitHub Profile
@ormergi
ormergi / passt-binding-cni-manifest-ocp.yaml
Created May 1, 2024 17:37
Deploy Passt binding CNI plugin on Openshift
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: passt-binding-cni
namespace: kube-system
---
apiVersion: security.openshift.io/v1
kind: SecurityContextConstraints
metadata:
@ormergi
ormergi / buid-passt-binding-cni-image.sh
Last active May 1, 2024 17:27
Deploy Kubevirt passt binding CNI on K8s
# Author: Or Mergi
#
# This script build basic container image to deploy Kubevirt passt binding CNI.
#
#
#!/bin/bash
curl -LO https://github.com/kubevirt/kubevirt/releases/download/v1.2.0/kubevirt-passt-binding
chmod +x kubevirt-passt-binding
cat <<EOF > Containerfile
@ormergi
ormergi / virt-launcher-nat-rules.sh
Created May 29, 2023 10:56
Kubveirt - dump VM pod NAT rules
# /bin/bash
set -ex
vm_name="myvmi"
vm_pod_name=$(kubectl get po -o custom-columns=:.metadata.name --no-headers | grep $vm_name | grep Running)
vm_node_name=$(kubectl get po $vm_pod_name -o custom-columns=:.spec.nodeName --no-headers)
vm_node_virt_handler_pod=$(kubectl get pod -n kubevirt -l kubevirt.io=virt-handler -o wide --no-headers | grep "$vm_node_name" | awk '{print $1}')
vm_pod_pid=$(kubectl exec -it $vm_node_virt_handler_pod -n kubevirt -c virt-handler -- bash -c "ps -ef | grep /usr/bin/virt-launcher.*--name.*$vm_name" | grep -Pv "grep|virt-launcher-monitor" | awk '{print $2}')
@ormergi
ormergi / iterate.sh
Last active May 29, 2023 11:39
Kubevirt development automation for Kubevirt updates and backward compatabilty scenerios
# This script enable faster development iterations in Kubevirt
# when working on a change that might affect backward compatibility,
# upgrades or legacy VMs (a VM that existed before an upgrade) disruption.
#
# Use case:
# 1. Changing virt-launcher pods secondary networks interfaces name scheme.
# Different network interfaces name-schemes breaks migration for legacy VMs
# when Kubevirt is updated.
#
# In order to test this, its necessary to have both versions images,
@ormergi
ormergi / demo-allocated-vfs-reset-issue.sh
Last active August 30, 2022 14:06
Demo Allocated SR-IOV VFs Reset Issue
# Author: Or Mergi <ormergi@redhat.com>
#
# This script runs a demonstration to reproduce the following issue:
# https://github.com/k8snetworkplumbingwg/sriov-cni/issues/219
#
# Warnings:
# * This script creates pods and re-configure you cluster node
# SR-IOV Physical Function (PF) interface and its Virtual Functions (VF).
# * Do not run this on production cluster.
# * Make sure no VF is attached to any workload on the node you picked.
@ormergi
ormergi / connect-netns-w-bridge.sh
Created May 24, 2022 15:12
Connect network namespaces with linux-bridge and veth's
#! /bin/bash
set -ex
function cleanup() {
set +e
ip netns exec blue ip link del dev veth-blue
ip netns exec red ip link del dev veth-red
ip netns del blue
ip netns del red
#!/bin/bash
set -ex
CRI=${CRI:-podman}
# download kind
kind="./kind"
! [ -f $kind ] && \
curl -L "https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-linux-amd64" -o $kind && \
#!/bin/bash
set -ex
CRI=${CRI:-podman}
kind="./kind"
! [ -f $kind ] && \
wget -nv "https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-linux-amd64" -O $kind && \
chmod +x $kind
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: sriov-net-vlan100
namespace: default
annotations:
k8s.v1.cni.cncf.io/resourceName: kubevirt.io/sriov_net
spec:
config: |
{