Part 1 — Getting Started


A reference before exam

Why Azure?

Market place — partner solutions optimized to run in azure, over 8000 solutions so far

Infra —
uses virtualization
os and hardware separated using hypervisor

Each server rack is attached with fabric controller software
Multiple server racks are connected through network switch
Orchestrator is responsible to get the requests through web api and sends it to switch that chooses best rack
Once the request reaches server, it will create the requested resource in a vm

10 broad categories:
compute — scale compute
network — on prem experience, vpn…


Network Policy

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: test-network-policy
namespace: default
spec:
podSelector:
matchLabels:
role: db
policyTypes:
- Ingress
- Egress
ingress:
- from:
- ipBlock:
cidr: 172.17.0.0/16
except:
- 172.17.1.0/24
- namespaceSelector:
matchLabels:
project: myproject
- podSelector:
matchLabels:
role: frontend
ports:
- protocol: TCP
port: 6379
egress:
- to:
- ipBlock:
cidr: 10.0.0.0/24
ports:
- protocol: TCP
port: 5978

Config Maps

apiVersion: v1
kind: ConfigMap
metadata:
name: game-demo
data:
# property-like keys; each key maps to a simple value
player_initial_lives: "3"
ui_properties_file_name: "user-interface.properties"

# file-like keys
game.properties: |
enemy.types=aliens,monsters
player.maximum-lives=5

user-interface.properties: |
color.good=purple
color.bad=yellow
allow.textmode=true

The KUBECONFIG environment variable holds a list of kubeconfig files.


Node & Pod Affinity/Anti-Affinity, Taints and Tolerations

Scheduler is a Kubernetes controller listening if a new pod is created and figure out right node by filtering and scoring

Node Affinity/Anti-Affinity

Affinity: If we need a pod to be in a node, based on key-label and value-label
Anti-Affinity: We don't want two replicas of pods in the same node

Node Affinity

Pod Anti-Affinity


Load balancing, Networking plugins, CNI

Docker Networking

3 default networking types — None, Host, Bridge (docker0 network)

Containers are launched on Docker bridge

Advanced Concepts — Stateful applications

This article is part 2 of https://amulyareddyk97.medium.com/advanced-kubernetes-with-doks-d5fdd829eed4. Please go through the link.

# Containers are not persistent
# PV is accessible at cluster level, independent of pods
# PVs life cycle is not tied to container lifecycle
# Types = Static PV and Dynamic PV

Static PV

static-pv.yml
kubectl create -f static-pv.yml
kubectl get pv
kubectl get pv <name>

Life cycle of PV and PVC

# PV is at cluster level
# When developer claims PVC is created at container level


A distributed streaming platform

What is Kafka for?

Is a producer consumer system.

Terminology

Kafka in Spring

Annotation : @KafkaListener

Logic

import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.kafka.annotation.KafkaListener;
import org.apache.kafka.clients.admin.NewTopic;
private final TaskExecutor exec = new SimpleAsyncTaskExecutor();@KafkaListener(id = "fooGroup", topics = "topic1")
public void listen(Foo2 foo) {
this.exec.execute(() -> {} );
}
@Bean
public NewTopic topic() {
return new NewTopic("topic1", 1, (short) 1);
}

Controller

@Autowired private KafkaTemplate<Object, Object> template; @PostMapping(path = "/send/foo/{what}") 
public void sendFoo(@PathVariable String what) {
this.template.send("topic1", new Foo1(what));
}

Kafka APIs

Admin API (inspect topics), Producer API (write), Consumer API (read), Kafka Streams API, Kafka Connect API


Shark, MLpack, Dlib, OpenCV Libraries

SHARK

Used in: Regression tasks

Installation:

sudo apt-get install cmake cmake-curses-gui libatlas-base-dev libboost-all-dev# Download package
mkdir build
cd build
cmake ..
make -j

Headers:

#include <shark/ObjectiveFunctions/Loss/SquaredLoss.h>
#include <shark/Algorithms/Trainers/LinearRegression.h>

Compile:

-std=c++11 -lboost_serialization -lshark -lcblas

MLPACK

Used in: Clustering tasks

Installation:

apt-get install libboost-math-dev libboost-program-options-dev libboost-test-dev libboost-serialization-dev libarmadillo-dev binutils-devsudo apt-get install libmlpack-dev
(or)
sudo apt-get install mlpack-bin

Headers:

#include <mlpack/methods/kmeans/kmeans.hpp>
#include <armadillo>

Compile:

std=c++11 -larmadillo -lmlpack -lboost_serialization

DLIB

Used in: Clustering and lot more algorithms

Installation:

Download dlib source

mkdir build
cd build
cmake ..
cmake -build . --config Release

Headers:

#include <dlib/clustering.h>
#include <dlib/rand.h>

Compile:

g++ -I /home/admin/Programs/dlib-19.7/ /home/admin/Programs/dlib-19.7/dlib/all/source.cpp -lpthread -lX11…


Spring Boot

Parameters like password, db connection data, dev parameters, test parameters etc should be maintained in a separately called configuration. This is possible by maintaining .yml file or .properties file.

Amulya Reddy Konda

Consultant

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store