{"id":24849276,"url":"https://github.com/bugbiteme/ex316-study","last_synced_at":"2025-04-12T17:07:17.824Z","repository":{"id":197317509,"uuid":"698347121","full_name":"bugbiteme/EX316-study","owner":"bugbiteme","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-01T21:22:42.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T11:29:50.271Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bugbiteme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-29T17:53:50.000Z","updated_at":"2024-09-21T00:34:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"4ae8308d-bba5-4530-94d6-53ed53bd7aed","html_url":"https://github.com/bugbiteme/EX316-study","commit_stats":null,"previous_names":["bugbiteme/ex316-study"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2FEX316-study","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2FEX316-study/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2FEX316-study/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugbiteme%2FEX316-study/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bugbiteme","download_url":"https://codeload.github.com/bugbiteme/EX316-study/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248602312,"owners_count":21131616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-31T12:30:26.346Z","updated_at":"2025-04-12T17:07:17.788Z","avatar_url":"https://github.com/bugbiteme.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# EX316-study\n\n## useful commands\n\n- retrieve performance metrics\n```\n  watch vmstat -S M\n\n  swpd - amount of memory used in swap space\n\n  free - available free memory\n\n  wa - CPU wait  \n```\n## Configuring Kubernetes Networking for Virtual Machines\n\n## Connecting Virtual Machines to External Networks\nCreating a Linux Bridge network on worker nodes\n\nhttps://docs.openshift.com/container-platform/4.10/virt/virtual_machines/vm_networking/virt-attaching-vm-multiple-networks.html\n\nmay need to label worker nodes first and add a nodeSelector in the spec\n```\noc label node worker01 network-type=external\n\n(and then)\n\napiVersion: nmstate.io/v1\nkind: NodeNetworkConfigurationPolicy\nmetadata:\n   name: br-policy\nspec:\n  nodeSelector:\n    network-type: \"external\" \u003c-----!!!!!!\n  desiredState:\n    interfaces:\n.\n.\n.\n```\nCreating a network attachment definition  \n  \nhttps://docs.openshift.com/container-platform/4.10/virt/virtual_machines/vm_networking/virt-attaching-vm-multiple-networks.html  \n  \n```\napiVersion: \"k8s.cni.cncf.io/v1\"\nkind: NetworkAttachmentDefinition\nmetadata:\n  name: \u003cbridge-network\u003e \n  annotations:\n    k8s.v1.cni.cncf.io/resourceName: bridge.network.kubevirt.io/\u003cbridge-interface\u003e \nspec:\n  config: '{\n    \"cniVersion\": \"0.3.1\",\n    \"name\": \"\u003cbridge-network\u003e\", \n    \"type\": \"cnv-bridge\", \n    \"bridge\": \"\u003cbridge-interface\u003e\", \n    \"macspoofchk\": true, \n    \"vlan\": 1 \n  }'\n```\n## Configuring Storage for Virtual Machines\n- Creating a PV that declares an external NFS share\n- Need to have IP or FQDN of external storage\n- Need to have export path as well\n\n- OpenShift provides the following template when you create a pv via the web console\n```\napiVersion: v1\nkind: PersistentVolume\nmetadata:\n  name: example\nspec:\n  capacity:\n    storage: 5Gi\n  accessModes:\n    - ReadWriteOnce\n  persistentVolumeReclaimPolicy: Retain\n  storageClassName: slow\n  nfs:\n    path: /tmp\n    server: 172.17.0.2\n```\nThis needs to be updated \n```\napiVersion: v1\nkind: PersistentVolume\nmetadata:\n  name: \u003cpv name\u003e\nspec:\n  capacity:\n    storage: 5Gi\n  accessModes:\n    - ReadWriteOnly \u003c------ this may need to be updated based on the spcification\n  persistentVolumeReclaimPolicy: Retain  \u003c----- remove\n  storageClassName: slow \u003c----- remove\n  volumeMode: Filesystem \u003c----- ADD!!!\n  claimRef:    \u003c----- ADD!!! directives for attaching to a particular PVC\n    name: \u003cname of PVC\u003e \u003c----- ADD!!! PVC name to attach to\n    namespace: \u003cname space where PVC will reside\u003e \u003c----- ADD!!!\n  nfs:\n    path: /tmp\n    server: 172.17.0.2\n```\n\nFinal form for PV\n```\napiVersion: v1\nkind: PersistentVolume\nmetadata:\n  name: \u003cpv name\u003e\nspec:\n  capacity:\n    storage: 5Gi\n  accessModes:\n    - ReadWriteMany \n  volumeMode:  Filesystem \n  claimRef:   \n    name: \u003cname of PVC\u003e \n    namespace: \u003cname space where PVC will reside\u003e \n  nfs:\n    path: /\u003cpath\u003e\n    server: \u003cip or fqdn of nfs system\u003e\n```\n\nfor PVC creation, use the yaml template in the console to fill out the information.   \nDO NOT USE `storageclass` when using external fileshare\n\n## Restoring a snapshot volume to a PVC\n\n- Go to Storage -\u003e VolumeSnapshots to find the volume and restore as new PVC\n\n## Setting a node to maintenance mode and draining workloads to remaining nodes\n\n```\n$ oc adm cordon worker02\nnode/worker02 cordoned\n\n$ oc adm drain worker02 --ignore-daemonsets --delete-emptydir-data --force\n.\n.\n.\n(wait a sec)\n.\nnode/worker02 drained\n```\n## Creating a service between two running VMIs\n- given that each VMI has the label app=web\n\n(example vm config under \"template\")\n```\n  template:\n    metadata:\n      creationTimestamp: null\n      labels:\n        app: web \u003c----------(LOOK)\n        flavor.template.kubevirt.io/small: \"true\"\n```\n- create a `service` of type `ClusterIP` with a selector based on `app: web`\n\n```\napiVersion: v1\nkind: Service\nmetadata:\n  name: web\n  namespace: my-namespace\nspec:\n  type: ClusterIP\n  selector:\n    app: web\n  ports:\n  - port: 80\n    protocol: TCP\n    targetPort: 80\n```\n\nVerify two endpoints\n\n```\n$ oc get endpoints\nNAME   ENDPOINTS                    AGE\nweb    10.11.0.28:80,10.8.2.20:80   2m13s\n```\n## add a cookie annotation to a route object\n```\napiVersion: route.openshift.io/v1\nkind: Route\nmetadata:\n  annotations:\n    router.openshift.io/cookie_name: web\n```\n\n- calling the url using the cookie with curl\n```\n(create cookie)\n$ curl web.apps.ocp4.example.com -c /tmp/my_cookie\nWelcome to www1\n\n(use cookie)\n$ curl web.apps.ocp4.example.com -b /tmp/my_cookie\nWelcome to www1\n```\n## Adding a readiness probe to a VM that uses HTTP GET requests to test the /health \nhttps://docs.openshift.com/container-platform/4.10/applications/application-health.html\n```\napiVersion: v1\nkind: Pod\nmetadata:\n  labels:\n    test: health-check\n  name: my-application\nspec:\n  containers:\n  - name: my-container \n    args:\n    image: k8s.gcr.io/goproxy:0.1 \n    readinessProbe: \n      httpGet: \n        path: /health\n        port: 80\n      failureThreshold: 2\n      successThreshold: 1\n      periodSeconds: 5\n      timeoutSeconds: 2 \n```\n\n## Adding a i6300esb watchdog device to a VM to power off if OS is unresponsive\nhttps://docs.openshift.com/container-platform/4.10/virt/virtual_machines/advanced_vm_management/virt-configuring-a-watchdog.html\n\n```\napiVersion: kubevirt.io/v1\nkind: VirtualMachine\nmetadata:\n  labels:\n    kubevirt.io/vm: vm2-rhel84-watchdog\n  name: \u003cvm-name\u003e\nspec:\n  running: false\n  template:\n    spec:\n      domain:\n        devices:\n          watchdog:\n            name: \u003cwatchdog\u003e\n            i6300esb:\n              action: \"poweroff\" \n...\n```\n\n## A VM listens on TCP port 3306. Add a liveness probe that tests the service by sending requests to the TCP socket\nhttps://docs.openshift.com/container-platform/4.10/applications/application-health.html\n```\n# ...\nspec:\n  domain:\n     ....stuff....\n  livenessProbe:\n    initialDelaySeconds: 2 \n    periodSeconds: 2\n    tcpSocket: \n      port: 3306 \n    timeoutSeconds: 10 \n# ...\n```\n\n## Extra things you may want to brush up on:\n- whenever you make changes to a VMs yaml config, save and reload to ensure your changes are still there.  \n  Sometimes, if there is a mistake, it will be erased, and you will wonder why your probes aren't working.\n- one trick for creating readiness and liveness probes for VMs is to create a deployment, and use the form to creat\n  them, and then copy/paste it to vm config. Make sure `ReadienessProbe` is lowercase `readinessProbe`\n- Installing a yum repo in Linux\n```\n$ sudo yum-config-manager --add-repo http://www.example.com/example.repo\n\n$ sudo yum-config-manager --enable example\n```\n- user and group policy management in OpenShift\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugbiteme%2Fex316-study","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbugbiteme%2Fex316-study","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugbiteme%2Fex316-study/lists"}