July 1st 2022 - Day 1 of 3 day study bender

HAPPY Canada D'eh!



Today was a great day, got up early in the morning thanks to alerts stemming from a server failure. Finished troubleshooting and fixing that within half an hour and then was on to my day.


Started the day with lecture 4 of David Malan's CS50, the title for the lecture was Memory and just like the rest so far was an amazing one!

Key takeaways:

1) Hexadecimals rule! -> RGB which forms the basis for all our visual data can be represented in 3 Hexs ranging from 00 to FF indicating decimal values from 0 to 255 and their combinations can represent the entire visual spectrum. Hexadecimals are also used to identify memory locations and by convention they are usually prepended by '0x' so '0x10' is not decimal base 10 but hexadecimal 10.


2) Pointers -> Have heard so much about this, it's finally great to know what they actually are. Pointers are special variables that store location (memory address) of a particular piece of data.

In 'C' programming language -> int *p = &n;

Here, 'p' is a pointer variable that is storing the address of variable 'n'.

You can also get the value if you know the location by using the de-reference operation. This is the reverse of printing the address of a variable.

* The pointer size in 'C' depends on the size of memory on the system and the corresponding # of digits required to address all locations in the memory.


3) 'C' programming language does not have a native string data type, the way we go about storing string in memory is using an array to storage some values and then setting a pointer to memory address of the first value and since all data ends with '\0' special character, we know when the string ends.

* In 'C' programming language to start using strings -> 'typedef char *string;' is all we need to start using strings.

* We have issues with comparing strings because we end up comparing 2 different addresses instead of comparing the value itself which is why we use special functions like 'strcmp(str1, str2)'.


4) We can use dynamic memory allocation -> 'malloc' standing for memory allocation can be used to allocate uninitialized sequence of bytes. MAKE SURE TO INITIALIZE! If not, we can end up with Garbage Values that are left behind by previous runs/other programs.

* Always make sure to release the memory to prevent 'stack/buffer overflow' errors.

* Valgrind is a good tool to help visualize over errors

Here's a good visualization of what's happening under the hood:




5) 'scanf' is the OG way of reading user input data. 


-------------------------------------------------------------


Spent the remainder of the day playing around with the EKSWorkshop. Here are my notes/take away from what I've done so far:


EksWorkShop Notes (link):


1) So to start off, we setup our working environment -> We create a new AWS user with Console access and 'AdministrativeAccess' IAM policy.


We will be using a Cloud9 instance. We will go and start a new Environment under AWS Cloud9, with a t3.small instance type on Amazon Linux 2 platform. On this workspace, we expand the disk space, using boto3.


* of interest -> export instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)


On this workspace, we will install a few tools that we will require to work with the K8S cluster.

  1. kubectl

  2. awscli

  3. jq, envsubst, & bash-completion,

  4. yq

  5. Set the AWS Load Balancer controller version -> v2.4.1


Also, for this workspace, we create a new role with AdministratorAccess to the EC2 instances and attach this role to the EC2 instance running the Cloud9 workspace. We update the workspace with this role.


From here, we clone the repositories available at -> https://github.com/aws-containers


2) Now to launch the Kubernetes cluster itself, we will be using an IaaC tool called eksctl -> we have a YAML file iwth the desiredCapacity set to 3 and the instance type set to t3.small.


-----


1) The first beginner module is to install a K8S dashboard for better visualization, I'm skipping this one for now.


2) The 2nd module is to deploy a microservices type application. We have a 'Deployment' type object with NodeJS Backend API & Crystal Backend API. We use LoadBalancer type service for the frontend & ClusterIP (default service) type service for the nodejs backend.


3) 3rd module -> We install Helm which is a package manager for Kubernetes that packages multiple Kubernetes resources into a single logical deployment unit called a 'Chart'.


* of interest -> helm repo add stable https://charts.helm.sh/stable

                 helm repo update

                 helm search repo nginx

                 helm repo add bitnami https://charts.bitnami.com/bitnami

                 helm install <name> bitnami/nginx

                 helm create <chart_name>


4) 4th module -> Liveness & Readiness probes. You can do one of three checks -> httpGet, exec probe, & TCP probe.


5) 5th module -> This module is about auto-scaling which is one of the coolest parts of Kubernetes. We have HPA = Horizontal Pod Autoscaler & CA = Cluster Autoscaler. 


This module starts out by installing kube-ops-view from Henning Jacobs.


We deploy Kubernetes Metrics Server -> https://github.com/kubernetes-sigs/metrics-server. This metrics server collects resource metrics from Kubelets & exposes them in Kubernetes apiserver through Metric API for use by Hortizontal Pod Autoscaler & Vertical Pod Autoscaler.


After deploying the metrics server -> We deployed a sample application (found here -> https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#run-expose-php-apache-server).


After this we deploy a Cluster Autoscaler & deploy an app & scale the app to see if the cluster grows ->  we can find more information here -> https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/cloudprovider/aws


* of interest -> helm install kube-ops-view stable/kube-ops-view --set service.type=LoadBalancer --set rbac.create=True

                 IAM Roles can be associated with a Kubernetes service account.

Comments

Popular posts from this blog

Working with APIs using Python

Sorting Algorithms

Java Spring Development Journey