Skip to main content

Posts

Migrate CentOS8 to Rocky Linux 8

  The following steps will migrate your CentOS8 server to Rocky Linux 8. dnf -y install wget wget https://raw.githubusercontent. com/rocky-linux/rocky-tools/ main/migrate2rocky/ migrate2rocky.sh chmod a+x migrate2rocky.sh ./migrate2rocky.sh -r rm -rf /etc/yum.repos.d/backups /etc/yum.repos.d/CentOS-Linux- AppStream.repo.rpmsave /etc/yum.repos.d/CentOS-Linux- BaseOS.repo.rpmsave sync && init 6   That's it.

Migrate from CentOS7 to CentOS8

    The following steps will migrate a CentOS7 server to CentOS8. yum -y install epel-release yum -y install yum-utils rpmconf rm -f /etc/ issue.net ; mv /etc/issue.net.rpmsave /etc/ issue.net rpmconf -a # 5 times N rm -rf /etc/yum.repos.d/reece.repo yum clean all package-cleanup --orphans | egrep 'noarch|x86_64' | xargs -r -n 1 yum -y remove package-cleanup --leaves | egrep 'noarch|x86_64' | xargs -r -n 1 yum -y remove # do above until none found - leaves 4-5 times yum install -y dnf dnf remove -y yum yum-metadata-parser rm -Rf /etc/yum dnf -y upgrade dnf -y install http://vault.centos.org/8.5. 2111/BaseOS/x86_64/os/ Packages/{centos-linux-repos- 8-3.el8.noarch.rpm,centos- linux-release-8.5-1.2111.el8. noarch.rpm,centos-gpg-keys-8- 3.el8.noarch.rpm} dnf -y upgrade https://dl.fedoraproject.org/ pub/epel/epel-release-latest- 8.noarch.rpm cd /etc/yum.repos.d && mkdir backups && mv CentOS-* backups tee CentOS-Linux-BaseOS.repo<<...

Migrate from RHEL7 to CentOS7

    The following steps will convert a RHEL7 Linux server to CentOS7.   yum -y remove rhnlib redhat-support-tool redhat-support-lib-python rpm -e --nodeps redhat-release-server rpm -e --nodeps redhat-logos rpm -e --nodeps yum rpm -e redhat-indexhtml-7-13.el7. noarch rpm -qa | egrep -i "rhn|redhat" rm -rf /usr/share/doc/redhat-release/ /usr/share/redhat-release/   mkdir tmp && cd tmp curl -O http://mirror.centos.org/ centos/7/os/x86_64/RPM-GPG- KEY-CentOS-7 curl -O http://mirror.centos.org/ centos/7/os/x86_64/Packages/ yum-plugin-fastestmirror-1.1. 31-54.el7_8.noarch.rpm curl -O http://mirror.centos.org/ centos/7/os/x86_64/Packages/ yum-3.4.3-168.el7.centos. noarch.rpm curl -O http://mirror.centos.org/ centos/7/os/x86_64/Packages/ centos-release-7-9.2009.0.el7. centos.x86_64.rpm curl -O http://mirror.centos.org/ centos/7/os/x86_64/Packages/ centos-logos-70.0.6-3.el7. centos.noarch.rpm rpm --import RPM-GPG-KEY-CentOS-7 rpm -Uvh *.rpm yum clean...

Deprecating Networking Ingress API version in Kubernetes 1.22

  Intro Kubernetes deprecates API versions over time. Usually this affects alpha and beta versions and only requires changing the apiVersion: line in your resource file to make it work. However with this Ingress object version change, additional changes are necessary. Basics For this post I am quickly creating a new cluster via Kind (Kubernetes in Docker) . Once done, we can see which API versions are supported by this cluster (version v1.21.1). $ kubectl api-versions | grep networking networking.k8s.io/v1 networking.k8s.io/v1beta1 Kubernetes automatically converts existing resources internally into different supported API versions. So if we create a new Ingress object with version v1beta1 on a recent cluster version, you will receive a deprecation warning - and the same Ingress object will exist both in version v1beta1 and v1. Create $ cat ingress_beta.yaml apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata:   name: clusterpirate-ingress spec:   rules:  ...

Analysing and replaying MySQL database queries using tcpdump

Why There are situations where you want to quickly enable query logging on a MySQL Database or trouble shoot queries hitting the Database server in real-time. Yes, you can enable the DB query log and there are other options available, however the script below has helped me in many cases as it is non intrusive and does not require changing the DB server, state or configuration in any way. Limitations The following only works if the DB traffic is not encrypted (no SSL/TLS transport enabled). Also this needs to be run directly on the DB server host (as root / admin). Please also be aware that this should be done on servers and data you own only. Script This script has been amended to suit my individual requirements. #!/bin/sh tcpdump -i any -s 0 -l -w - dst port 3306 | strings | perl -e ' while(<>) { chomp; next if /^[^ ]+[ ]*$/;   if(/^(ALTER|COMMIT|CREATE|DELETE|DROP|INSERT|SELECT|SET|UPDATE|ROLLBACK)/i) {     if (defined $q) { print "$q\n"; }     $q=$_; ...

Exporting and importing docker images manually

  Why Sometimes it can be handy to have a copy of a container image locally or being able to manually copy a docker image from one computer to another.  Recently I had an issue where newly built Kubernetes worker nodes did not work properly due to the fact that the flannel pod image was hosted on quay.io , which was not available at the time. The "fix" was to manually export the image from a server which had flannel running just fine and import on the new worker nodes (and restart the flannel pods). Export Assuming we want to save / export the image below: $ docker images REPOSITORY     TAG       IMAGE ID       CREATED       SIZE kindest/node   <none>    af39c553b6de   2 weeks ago   1.12GB We run docker save with the image id and redirect the output into a new local file. $ docker save af39c553b6de > kindest-node.tar Once done, we end up with a new tar fi...

Create a Kubernetes cluster using kind (Kubernetes in Docker) in less than 2 minutes

Why Sometimes I just need to quickly test a K8s resource or compare a cluster with a near vanilla version. This is where kind comes in handy, as it can create a clean and fresh Kubernetes cluster in under 2 minutes. Requirements You have a working docker environment. Step 1 Download the kind binary (less than 4 MB). curl -Lso ./kind https://kind.sigs.k8s.io/dl/v0.11.0/kind-linux-amd64 && chmod 755 kind Step 2 Create the actual cluster. $ time ./kind create cluster Creating cluster "kind" ...  ✓ Ensuring node image (kindest/node:v1.21.1)  ✓ Preparing nodes  ✓ Writing configuration  ✓ Starting control-plane  ✓ Installing CNI  ✓ Installing StorageClass Set kubectl context to "kind-kind" You can now use your cluster with: kubectl cluster-info --context kind-kind Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community real     1m55.934s user    0m1.014s sys     0m0.970s Step ...