Ubuntu 18.04 to 22.04 in-place upgrade

My manage said we have many ubuntu 16.04, can you believe? Every single Ubuntu LTS comes with 5 years of standard support. During those five years, bug fixes and security patches will be provided. Ubuntu 18.04 ‘Bionic Beaver’ is reaching End of Standard Support this May. So today we are going to run in-place upgrade for Ubuntu 18.04 LTS to 22.04 LTS. Pre-upgrade checklist Validate current OS version and running service (nginx) # current OS version root@ubuntu-test:~# cat /etc/os-release NAME="Ubuntu" VERSION="18.04.6 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.6 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic # nginx service status root@ubuntu-test:~# echo "ubuntu-inplace-upgrade zack-testing-nginx-service!!" >> /var/www/html/index.html root@ubuntu-test:~# systemctl restart nginx root@ubuntu-test:~# curl localhost ubuntu-inplace-upgrade zack-testing-nginx-service!! Fully update the system # update system root@ubuntu-test:~# sudo apt update Hit:1 http://au.archive.ubuntu.com/ubuntu bionic InRelease Hit:2 http://au.archive.ubuntu.com/ubuntu bionic-updates InRelease Hit:3 http://au.archive.ubuntu.com/ubuntu bionic-backports InRelease Hit:4 http://au.archive.ubuntu.com/ubuntu bionic-security InRelease Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. root@ubuntu-test:~# sudo apt upgrade -y Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. # reboot system before upgrade root@ubuntu-test:~# sudo do-release-upgrade Checking for a new Ubuntu release You have not rebooted after updating a package which requires a reboot. Please reboot before upgrading. root@ubuntu-test:~# reboot Connection closing...Socket close. Take full system backup Here I took a VM snapshot before upgrade ...

28 August 2023 · 3 min · Zack Zhou

Move To Rancher

My current employer using Rancher, due to the vender prefers this?? So far many different ways I have used to deploy k8s cluster, each with its own pros and cons. home lab build k8s components (etcd, keepalived, apiserver, scheduler, coreDNS, calico) home lab k8s cluster with kubeadm k8s on AWS using kops and eksctl AWS self-managed k8s cluster directly on ec2 by ansible Rancher Support matrix Local docker Installation ...

26 June 2023 · 4 min · Zack Zhou

Kubespary with Terraform on AWS

Kubespary is a powerful and highly configurable tool that automates and supports deployment on various cloud providers (AWS, GCE, Azure, etc.) and on-premises infrastructure. In this post I will run its build-in Terraform and ansible code to provision a k8s cluster based on AWS EC2. Benefit of Kubespary We can define specific settings in cluster-config.yaml for networking, authentication, and other Kubernetes features, it also supports for multiple networking plugins (Calico, Flannel, Weave Net, etc.), By managing hosts file and rerun the playbook to make add or remove nodes easily, Integrated CI/CD Pipelines and Infrastructure as Code (IaC) with Terraform and Ansible to achieve automation. ...

24 May 2023 · 4 min · Zack Zhou

ZackBlog AWS Serverless webhosting

In this article, I will see how to host “zackweb” as a static web application using the following AWS serverless options: S3 static webhosting AWS CDK + CloudFront Prerequisite Add one more step in the existing Github Action workflow to copy the static web content to the newly created S3 bucket # edit github action workflow aws s3 cp ~/zack-gitops-project/zack_blog/_site/* s3://zackweb-serverless/ --recursive # validate content in s3 bucket ubuntu@ip-172-31-26-78:~$ aws s3 ls s3://zackweb-serverless --summarize PRE aboutme/ PRE assets/ PRE certificate/ PRE gitrepo/ PRE jekyll/ PRE pro/ PRE skillroadmap/ 2023-07-30 14:55:05 4455 404.html 2023-07-30 14:55:05 504 Dockerfile 2023-07-30 14:55:06 80555 feed.xml 2023-07-30 14:55:06 7760 index.html 2023-07-30 14:55:06 0 nginx.conf Total Objects: 5 Total Size: 93274 Option 1: S3 static webhosting ...

30 April 2023 · 3 min · Zack Zhou

Enable Free SSL certificate for blog

An interviewer told me this blog is insecure!! Generate free SSL certificate from https://zerossl.com/ Validate the Certificate with Private Key via https://www.sslshopper.com/certificate-key-matcher.html Upload ‘certificate.crt’ and ‘private.key’ to web server /etc/nginx/ssl/ Setting up NGINX HTTPS Server by including the ssl parameter to the listen directive in the server block under ‘http’ in ’nginx.conf’: http { server { listen 443 ssl; server_name zackdevops.online; ssl_certificate /etc/nginx/ssl/certificate.crt; ssl_certificate_key /etc/nginx/ssl/private.key; } ... } Fix 2 errors: 2023/02/07 10:29:33 [emerg] 73175#73175: "server" directive is not allowed here in /etc/nginx/nginx.conf:11 2023/02/07 10:30:25 [error] 73207#73207: *1 directory index of "/usr/share/nginx/html/" is forbidden,client: 163.53.144.82, server: zackdevops.online, request: "GET / HTTP/1.1", host: "zackdevops.online" 2023/02/07 10:30:36 [error] 73207#73207: *1 directory index of "/usr/share/nginx/html/" is forbidden, client: 163.53.144.82, server: zackdevops.online, request: "GET / HTTP/1.1", host: "zackdevops.online" Bingo! https://zackdevops.online connection is secure!

7 February 2023 · 1 min · Zack Zhou

Ansible for AWS Dynamic Inventory

When using Ansible with AWS, maintaining the inventory file will be a hectic task as AWS has frequently changed IPs, autoscaling instances, and much more. Here we will install and apply ansible plugin for AWS dynamic inventory which makes an API call to AWS to get the instance information in the run time. It gives the EC2 instance details dynamically to manage the AWS infrastructure. It supports most of the public and private cloud platforms not limited to just AWS. ...

22 January 2023 · 2 min · Zack Zhou

Redis cluster with Helm

Today we are playing around with Redis, Here we use helm to install Redis cluster, then validate statefulset storage and cluster availability. Typical Redis cluster (3 master + 3 slave for slots) Topology: Helm install bitnami/redis-cluster helm repo add bitnami https://charts.bitnami.com/bitnami helm pull bitnami/redis-cluster kubectl create ns redis helm install zz-redis bitnami/redis-cluster -n redis Redis-cluster status kubectl get po | grep zz-redis zz-redis-redis-cluster-0 1/1 Running 3 (33m ago) 36m zz-redis-redis-cluster-1 1/1 Running 1 (32m ago) 36m zz-redis-redis-cluster-2 1/1 Running 1 (33m ago) 36m zz-redis-redis-cluster-3 1/1 Running 1 (33m ago) 36m zz-redis-redis-cluster-4 1/1 Running 1 (33m ago) 36m zz-redis-redis-cluster-5 1/1 Running 1 (33m ago) 36m kubectl get svc zz-redis-redis-cluster ClusterIP 10.96.68.34 <none> 6379/TCP 37m zz-redis-redis-cluster-headless ClusterIP None <none> 6379/TCP,16379/TCP 37m kubectl get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE redis-data-zz-redis-redis-cluster-0 Bound pvc-81f69c15-2f59-4704-9fec-c3ab217ebca5 1Gi RWO rook-ceph-block 37m redis-data-zz-redis-redis-cluster-1 Bound pvc-871dbb68-a78b-48a8-8feb-8726eb8a795e 1Gi RWO rook-ceph-block 37m redis-data-zz-redis-redis-cluster-2 Bound pvc-afd8c82e-c314-426a-a3cd-3c8d10b42bb1 1Gi RWO rook-ceph-block 37m redis-data-zz-redis-redis-cluster-3 Bound pvc-e8fd5d47-dd60-4358-8cf5-a17d6574bbe2 1Gi RWO rook-ceph-block 37m redis-data-zz-redis-redis-cluster-4 Bound pvc-04d4f148-b7c1-407e-b9a8-b2fa911405f0 1Gi RWO rook-ceph-block 37m redis-data-zz-redis-redis-cluster-5 Bound pvc-99e8b2cc-c5d5-4636-a19b-042922eca3cc 1Gi RWO rook-ceph-block 37m Validate cluster by set key ...

9 December 2022 · 2 min · Zack Zhou

Apache Kafka cluster with testing topics

Apache Kafka has proven to be an extremely popular event streaming platform, as its scalable distributed architecture, high performance, and use cases, some key terms and concepts as below: Kafka clusters and Kafka brokers Kafka clients and servers Producers, and Consumers, and Consumer groups Kafka topics & Kafka partitions, offsets Kafka topic replication, leaders, and followers ZooKeeper or not Typical Kafka Topology: Helm install bitnami/kafka Here we use helm to install Kafka, then validate statefulset storage and cluster availability by creating a topic, producer, and consumer. ...

9 December 2022 · 2 min · Zack Zhou

Ingress controller for Subdomain based Routing

In this post I will run the steps required to set up MetalLB for LoadBalancer IP allocation, the NGINX Ingress Controller for routing traffic based on subdomains, and how to configure local DNS to enable subdomain-based routing for Kubernetes services. Ingress-nginx install We will use Helm to install our ingress controller ingress-nginx, which will be used to route traffic based on subdomains. # install ingress controller ingress-nginx helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm repo update helm -n ingress-nginx install ingress-nginx ingress-nginx/ingress-nginx --create-namespace # check for ingressclasses kubectl get ingressclasses.networking.k8s.io NAME CONTROLLER PARAMETERS AGE nginx k8s.io/ingress-nginx <none> 149m MetalLB for loadbalancing ...

18 November 2022 · 3 min · Zack Zhou

Rook-Ceph for dynamic Persistent Volume

Today, I will explore how to install and configure Persistent Volume for all the deployment in K8S to consume. Helm install Rook-Ceph for persistent storage Configure local VM block storage to add 50Gb sdb to all k8s master and worker nodes Install rook-ceph cluster git clone --single-branch --branch master https://github.com/rook/rook.git cd rook/deploy/examples kubectl create -f crds.yaml -f common.yaml -f operator.yaml kubectl create -f cluster.yaml Ceph toolbox to check cluster status kubectl create -f toolbox.yaml kubectl -n rook-ceph exec -it deploy/rook-ceph-tools -- bash ceph status ceph osd status ceph df rados df Ceph Dashboard service for HTTPS login kubectl create -f dashboard-external-https.yaml kubectl -n rook-ceph get secret rook-ceph-dashboard-password -o jsonpath="{['data']['password']}" | base64 --decode && echo Create storage pool and storage class kubectl create -f pool.yaml cd csi/rbd kubectl create -f storageclass.yaml Set “rook-ceph-block” as the default storage class kubectl patch storageclass rook-ceph-block -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' kubectl get sc NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE rook-ceph-block (default) rook-ceph.rbd.csi.ceph.com Delete Immediate true 8d Check pool and OSDs in Ceph web UI ...

9 November 2022 · 1 min · Zack Zhou