Friday, March 10, 2023

Docker and Kubernetes

(Kubernetes aka k8s)



Kubernetes CLI

KubeCtl CLI doc



Kubernetes cheat sheet

K8s CLI Cheat sheet

CLI Quick ref

Docker Compose Kubernetes Cheat sheet



Kubernetes - Contexts

src: Docker: Kubernetes - intro - CLI example

kubectl config get-contexts

kubectl config use-context docker-desktop

kubectl get nodes

kubectl config view



Kubernetes - Orchestration example - running Pods:

src: Docker Kubernetes orchestration - short CLI reference

kubectl apply -f pod.yaml

kubectl get pods

kubectl logs demo

kubectl delete -f pod.yaml



Deploy to Kubernetes

(Containerize, Kubernetize, run)

Containerize

Containerize your application - Create image getting-started

git clone https://github.com/docker/getting-started.git

cd getting-started\app

copy con Dockerfile

# syntax=docker/dockerfile:1

FROM node:18-alpine

WORKDIR /app

COPY . .

RUN yarn install --production

CMD ["node", "src/index.js"]

EXPOSE 3000

^Z

docker build -t getting-started .

rem docker run -dp 3000:3000 getting-started

rem start http://localhost:3000

Kubernetize and run

src: Deploy to Kubernetes

Deploy, list, check, remote:

kubectl apply -f bb.yaml

kubectl get deployments

kubectl get services

start http://localhost:30001/

kubectl delete -f bb.yaml



Convert Docker Compose to Kubernetes

CLI kompose

Converts docker-compose.yaml to kubernetes-service.yaml



Kubernetes Dashboard

Web UI Dashboard

Create sample user

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml

kubectl proxy

start http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

kubectl delete -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml

*

kubectl -n kubernetes-dashboard delete serviceaccount admin-user

kubectl -n kubernetes-dashboard delete clusterrolebinding admin-user



Kubernetes Dashboard - in Docker container (have not tested yet)

src: https://hub.docker.com/r/kubernetesui/dashboard

docker pull kubernetesui/dashboard



Namespaces

Namespaces intro

kubectl get namespaces

kubectl get namespaces --show-labels

Create DEV namespace:

kubectl create -f https://k8s.io/examples/admin/namespace-dev.json



Kubernetes config

src: StackOverflow

Config Example

--kubeconfig

KUBECONFIG=$HOME/.kube/config

~/.kube/config # Linux

%USERPROFILE%/.kube # Windows



Kubernetes config file

src: DevOpsCube: KubeConfig file

kubectl -n kube-system create serviceaccount devops-cluster-admin



Kubernetes short tutorial

Docker and Kubernetes at TutorialPoint



See also

*

Docker: Get started with Kubernetes - build docker k8s ready apps

Docker: Play with Kubernetes

Kubernetes - home

*

Kubernetes: deprecating Docker, switch to other containers (containerd or CRI-O) (Open Container Initiative)

Kubernetes: Dockershim deprecation FAQ

MS: Kubernetes vs Docker - cz



Docker limits cpu memory

Docker memory CPU limits (Windows)



for WSL2, create or open file:

%USERPROFILE%\.wslconfig

not: %HOMEPATH%\.wslconfig

Note: you have to save it in Linux LF (not Windows CRLF) mode



Add or update lines:

memory=3GB

processors=1

#kernel=C:\\temp\\myCustomKernel

#kernelCommandLine = vsyscall=emulate

swap=8GB

swapfile=C:\\temp\\wsl-swap.vhdx

pageReporting=true

#localhostforwarding=true

#nestedVirtualization=false

#debugConsole=true



src:

Microsoft Learn: example .wslconfig

src: Google search

StackOverflow: The Memory and CPU settings were removed for WSL2 integration



You have to stop all running WSL2 containers for changes to take effect.



Stop WSL2:

wsl --shutdown



Saturday, July 09, 2022

SQL basic course základní kurz


SQL basic course základní kurz

Fakt pro začátečníky, žádný pokročilý věci.


SQL na českých stránkách:

https://www.google.com/search?q=sql+site%3Acz


Spousta kvalitních výukových materiálů úplně zdarma a česky:

https://www.itnetwork.cz/mysql/mysql-tutorial-uvod-a-priprava-prostredi


Tady je úplný úvod do SQL:

https://www.itnetwork.cz/mysql/mysql-tutorial-vytvoreni-databaze-a-tabulky

Nemusíš to zdlouhavě číst, to v černém rámečku jsou příkazy jazyka.

Vždy na konci článku je odkaz na další díl.


Obrázky jsou otisky obrazovky z pracovního prostředí, zde PhpMyAdmin, které je jedno z možných.

Pro znalost a práci s SQL žádné takové prostředí nepotřebuješ, stačí ti znát ty příkazy v černém rámečku.


Souhrn základních SQL příkazů:

CREATE DATABASE `it_school`;

DROP DATABASE `it_school`;

CREATE TABLE user (

    id int NOT NULL AUTO_INCREMENT PRIMARY KEY,

    title_before varchar(20),

    first_name varchar(20),

    last_name varchar(20),

    title_after varchar(20),

    birth_date date,

);

INSERT INTO `user`

    (`title_before`, `first_name`, `last_name`, `title_after`, `birth_date`)

    VALUES (`Ing.`, `Pavel`, `Dvorak`, `PhD.`, `2000-12-31`);

INSERT INTO `user`

    (`title_before`, `first_name`, `last_name`, `title_after`, `birth_date`)

    VALUES (`Mgr.`, `Karel`, `Sovak`, NULL, `2001-11-30`),

    VALUES (`Bc.`, `Jiri`, `Mlady`, NULL, `2002-10-29`),

    VALUES (NULL, `Pavel`, `Stary`, NULL, `2003-09-28`);

SELECT * FROM USER;

UPDATE `user` SET `title_after` = `Doc.` WHERE `id` = 1;

SELECT * FROM USER;

DELETE FROM `user` WHERE `id` = 1;

DELETE FROM `user` WHERE `id` IN (2, 3, 5);


JavaScript programming basics


Základy programování v JavaScriptu


Úkol pro tebe. Připravil jsem ti hotový mini-program v JavaScriptu s Fibonacciho posloupností. Mám 2 varianty, rozhodni, která je lepší. Můžeš to upravovat rovnou v prohlížeči, výsledek je hned vidět vpravo.


Pro tyhle začátky je úplně jedno, zda Java nebo JavaScript, jde o princip a tady rovnou vidíš výsledek v pravém panelu.


Hotový program:

Fibonacci sequence:

Recursion:

https://jsbin.com/gopemiloki/edit?js,output

For loop:

https://jsbin.com/nakavuhuli/edit?js,output

https://jsbin.com/mayalijowa/edit?js,output


Úkol:

1. Podívej se na program, 1. i 2. variantu

1.a. Která varianta je lepší a proč?

2. Zkus si to naprogramovat sám znova (uprostřed šedé menu File / Clone, ať si nepřepíšeš originál, kdyžtak je originál ještě v příloze tohohle mailu)

3. Zkus nějakou změnu, úpravu (menu File / Clone)


Úkol:

Co je lepší a proč?

Zkus si to upravit.


Odkazy:

Co je to rekurze (nečti to celý)

https://cs.wikipedia.org/wiki/Rekurze_(programov%C3%A1n%C3%AD)

JavaScript cyklus for:

https://www.w3schools.com/js/js_loop_for.asp

- nečti to, jen klepni na Try it Yourself a zkus si něco sám


IT basic course základní kurz


Základní kurzy IT

Fakt základ, ukázky, nic pro profíky!


Keywords:

IT basic course 

IT základní kurz


Content:

Odkazy, poznámky, příklady základních úvodů do IT, programování, správy systémů atd.

Občas se mě lidi ptají, jak se naučit něco z IT, tak shromažďuji pár základních poznámek, klíčových slov a odkazů.


Články:

Základy programování v JavaScriptu (můj příklad v JavaScriptu)

Úvody do SQL (česky a s příkladama)


Algoritmy:

Fibonacci heap - Fibonacci heap CZ


Wednesday, February 02, 2022

Monday, September 27, 2021

Git unplugged notes

Git unplugged notes



Rebase issue

# If someone rebases on public branch, after pull all others could see:

Your branch and 'origin/branch1' have diverged,

and have 2 and 3 different commits each, respectively.

Solution

git fetch origin

git reset --hard origin/main

src stackoverflow



Rebase issue

Your branch is ahead of 'origin/master' by 3 commits

Solution

git fetch -p # clean up local branches

git pull --rebase # pull and rebase my local commits on top of incoming

Better solution (unchecked)

Step 1 : git checkout branch1

Step 2 : git pull -s recursive -X theirs # merge strategies

Step 3 : git reset --hard origin/branch1



Rebase issue explained (long)

git rev-list --count --left-right branch1...upstream

git rev-list --count --left-right origin/master...HEAD

*

# to see if the local repository is ahead, push needed:

git rev-list origin..HEAD

# to see if the local repository is behind, pull needed:

git rev-list HEAD..origin

# if you have numbers for both, then the two repositories have diverged:

git rev-list --count --left-right origin/master...HEAD

src: stackoverflow

src: https://stackoverflow.com/a/40990959

src-long: https://stackoverflow.com/a/66981730



# squash - reset soft:

#git reset --soft master

git reset --soft origin/master

git add -A

git commit

git push --force



# squash - reset to merge-base:

git checkout branch1

git reset $(git merge-base master $(git branch --show-current))

git add -A

git commit

git push --force

# src: https://stackoverflow.com/questions/25356810/git-how-to-squash-all-commits-on-branch

# Note: git merge-base branch2 branch3



Squash

# squash - merge squash:

git checkout origin/master

git merge --squash origin/branch1

git commit

git push --force



Git branch_name vs refs

git show-ref origin/main

1. If $GIT_DIR/<refname> exists, that is what you mean (this is usually useful only for HEAD, FETCH_HEAD, ORIG_HEAD, MERGE_HEAD and CHERRY_PICK_HEAD);

2. refs/<refname> if it exists;

3. refs/tags/<refname> if it exists;

4. refs/heads/<refname> if it exists;

5.  refs/remotes/<refname> if it exists;

6. refs/remotes/<refname>/HEAD if it exists.

src: stackoverflow.com

Long aside: how this all works (read only if sufficiently curious) :

src: stackoverflow.com



Git server repository (docker git repo)

Alpine Git client

JKarlos Docker Git server

Gogs and Podman Git server

Gogs Git server

Gogs by Pirates - GitHub like Git server

Gitea in Docker - demo - github

GitColony docker server - obsolete



Git server:

Google it:

https://www.google.com/search?q=gnu+gpl+git+server

Git server list - wiki:

https://en.wikipedia.org/wiki/Git#Git_server

Gerrit:

Home: https://www.gerritcodereview.com/

Wiki: https://en.wikipedia.org/wiki/Gerrit_(software)

GitOlite:

https://gitolite.com/gitolite/index.html

Wiki says: External projects like gitolite, which provide scripts on top of git software to provide fine-grained access control.

*

FLOSS:

Gogs

Gitea = fork of Gogs



Git Web interface self-hosted:

https://www.google.com/search?q=git+web+interface+self-hosted

Options – list – good overview:

https://www.cyberciti.biz/open-source/github-alternatives-open-source-seflt-hosted/

GitLab = web git, “Confluence” wiki, “Jira” tracker

https://gitlab.com/gitlab-org/gitlab-foss

Gitea – community fork of Gogs:

https://gitea.io/

Savannah = GNU = free software foundation (FSF)

http://savannah.gnu.org/projects/administration

GitBucket – Open source

https://github.com/gitbucket/gitbucket

Gogs - self hosted Git:

https://gogs.io/

*

Awesome Selfhosted:

https://github.com/awesome-selfhosted/awesome-selfhosted

GitWeb:

https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb

*

BitBucket.org

GitHub.com


Git web UI – including proprietary and closed-source:

https://www.slant.co/topics/1440/~best-self-hosted-web-based-git-repository-managers

https://www.slant.co/topics/425/~best-git-web-interfaces



Thursday, August 12, 2021

Lodě Sázava 2021 (FAV)


KDY / WHEN:

Neděle / Sunday

15. 8. 2021

9:00 – 18:00



TRASA / ROUTE:

Sázava

Sázava - mapy

*

VLAK / TRAIN:

from destination to start for car drivers

Kácov (dest) - Zruč n. S (start)

Kácov (dest) - Zruč n. S (start) - Friday 22

TRAIN WALK:

Zruc NS from Train to start Camp Rakosi

*

START:

Výdej lodí / issuing canoes: 9.00–10.00

Zruč nad Sázavou

Kemp Rákosí

Start - Google maps point

bisport premise ZrucNS

*

PŘESKOČIT / AVOID (pomalí / slow service):

Tůmův Chabeřický mlýn

*

ODBOČKA / FORK (suggested):

Želivka fork, short break, refreshment, crystal clear cold water

*

BREAK (doporučený / suggested):

Kemp Omaha - gallery

nice weir

good kiosk - sausages, local beer, pancakes, coffee

it was perfect on last summer, I hope they keep the quality

*

CÍL / END:

Kácov

Kácov rental - Google maps point

Sběr lodí / return canoes: 15.00–19.00

bisport premise Kacov



KDO / WHO:

2 MarS single

2 MaD + Smita

3 Petr + Tamara + Ráša

2 Jiří + tatínek



PÚJČOVNA / RENTAL:

Bisport Kácov s.r.o., Kácov 158

https://www.bisport.cz/pujcovna-lodi

Mail: info@bisport.cz

Tel: + 420 777 335 618



PLATBA / PAYMENT:

Č.Ú. / Account: ***

Zpráva / Message: Your Name, Sazava 2021

*

ČÁSTKA / AMOUNT:

MarS: 399 CZK

MaD: 399 CZK

Jiri 2-seats: 399 CZK

Petr 3-seats: 555 CZK

*

PÚV CENA / ORIG PRICE:

Vydra 2 seats: 420 CZK / 1 canoe

Rivera 3 seats: 585 CZK / 1 canoe

sleva / discount: 5%



PÚJČOVNA / RENTAL – others:

Dronte (na Sázavě outsourcuje přes BiSport)

Samba (Ohře Ondra K a Anička letos, asi i loni a dříve)

Půjčovna Samba – stejná



KEYWORDS:

Canoe kanoe kánoe Sázava Sazava 2021 FAV



Sunday, July 11, 2021

Docker networking


Create bridge

docker network create -d bridge mars_bridge


Run container inside specific network (i.e. Redis and Redis CLI)

docker run --name some-redis --network mars_bridge --rm -d redis

docker run -it --network mars_bridge --rm redis redis-cli -h some-redis


Connect container to network

docker network connect mars_bridge some-redis


Disconnect container from network

docker network disconnect mars_bridge some-redis


List Docker networks

docker network ls


Remove Docker network

docker network rm mars_bridge


Remove all unused networks

docker network prune


Inspect Docker network

docker network inspect mars_bridge


Inspect with formatted output

docker inspect --format='{{json .NetworkSettings.Networks}}'  some-redis

docker inspect --format="{{json .NetworkSettings.Networks}}" some-redis

docker inspect --format="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" some-redis


Sources

Docker - networking containers

Docker Hub - Redis (as an example of Docker-networked container)


Docker notes unplugged

 My Docker notes - crossroads



Docker orchestration with Kubernetes k8s

My Docker Kubernetes k8s notes



Docker memory CPU limits (Windows)

My Docker limits - cpu memory notes



Docker network configuration

My Docker networking notes

src: docs.docker.com



Docker Swarm stack deploy

My Docker Swarm stack deployment notes

src: docs.docker.com



See also

My AWS - Amazon Web Services - notes

DockerCon 2021 - conference

PlayWithDocker - play, 101tut, lab, get started, training


Tuesday, July 06, 2021

AWS - Amazon Web Services - notes

AWS - Amazon Web Services - notes

My unsorted notes about AWS


AWS general xroad

Home

Console

* console FFT Frankfurt

CLI

Sign in

Trainings all

Trainings and Certifications blog post

aws.training site


10 miutes tutorials crossroad

10 min tut xroad

WordPressServerLessReactLinux VMMySQLStatic S3PostgreSQL


Popular AWS - services crossroads

Free Tier, Elastic Beanstalk, DynamoDB, RDS (Relational Database Service), CloudFront, Glacier


LightSail

 - servers and services management console

 -  easily setup your service

LightSail tutorials home

LightSail home page


EC2

- Elastic Compute Cloud

EC2 pricing

EC2 get started - LAMP, Elastic, WordPress, etc

* WordPress 10 min tut


S3

- Simple Storage Service

S3 home

S3 get started



Lambda

 - serverless computing

Lambda home

Lambda - get started - crossroad

Lambda - resources

Lambda - build basic web app

Lambda - ServerLess web app tutorial

* ServerLess with Lambda, API GateWay, Amplify, DynamoDB, Cognito