вівторок, 14 листопада 2023 р.

Kubernetes. Basics. 2. Namespaces

 


Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called Namespaces.

In Kubernetes, a namespace is a virtual cluster or a logical boundary that provides a way to organize and isolate resources within a cluster. It is primarily used to create multiple virtual clusters within a single physical cluster, allowing teams or applications to have their own isolated environments.

Namespaces provide the following benefits:

1. Resource isolation: Each namespace provides a separate scope for resources such as pods, services, deployments, and config maps. This ensures that resources within one namespace do not conflict with resources in another namespace.

2. Access control: Namespaces enable access control and resource management. Role-Based Access Control (RBAC) policies can be applied at the namespace level, allowing fine-grained control over who can access and manage resources within a namespace.

3. Organization and management: By grouping related resources together in namespaces, it becomes easier to manage and organize applications, environments, or teams within a cluster. It improves the clarity and separation of concerns.

4. Resource quota and limits: Namespaces can have resource quotas and limits applied to them, ensuring that resources are allocated fairly and preventing any single namespace from consuming excessive resources.

Note that:

  • Namespaces divide cluster resources logically
  • Nodes are VMs

Kubernetes cluster starts with 4 initial namespaces:

  • default - The default namespace for objects with no other namespace
  • kube-system - The namespace for objects created by the Kubernetes system
  • kube-public - This namespace is created automatically and can be read by all users (including those not authenticated). This namespace is mostly reserved for cluster usage, in case that some resources should be visible and readable publicly throughout the whole cluster. The public aspect of this namespace is only a convention, not a requirement.
  • kube-node-lease - This namespace holds Lease objects associated with each node. Node leases allow the kubelet to send heartbeats so that the control plane can detect node failure.

Working with most of the resources in Kubernetes requires providing namespace name explicitly:

$ kubectl get pods -n kube-system

Working with Namespaces

Viewing Namespaces:

$ kubectl get namespaces
NAME                STATUS   AGE
kube-system         Active   5m17s
default             Active   5m17s
kube-public         Active   5m17s
kube-node-lease     Active   5m17s
$ kubectl get namespaces --show-labels
$ kubectl get ns ${NS_NAME}
$ kubectl describe ns ${NS_NAME}

Viewing Resources in Namespace:

## For default Namespace:
$ kubectl get pods
$ kubectl get deployment

## Working with other namespaces:
$ kubectl get pods -n ${NS_NAME}
$ kubectl get rs -n ${NS_NAME}
$ kubectl get all -n ${NS_NAME}

## Getting Pods from All Namespaces:
$ kubectl get pods -A
$ kubectl get pods --all-namespaces

Documentation:

Please answer the following question:

Q1 How many namespaces are currently created in the cluster?

Q2 How many resources (all) are created in kube-system namespace?

Q3 Check the labels and find “what namespace Santa doesn’t like”

Q4 What Pod is running in “red” namespace?

Q5 What “rs” (Replica Set) is running in “red” namespace?

четвер, 26 жовтня 2023 р.

понеділок, 3 липня 2023 р.

Create and Manage Cloud Resources

gcloud auth list


gcloud config list project


gcloud config set compute/region us-west3


gcloud config set compute/zone us-west3-c



#####################################

Task 1. Create a project jumphost instance

#####################################



make manualy


Create a project jumphost instance

gcloud compute instances create nucleus-jumphost-891 --zone us-east1-c  --machine-type=f1-micro   --image-family=debian-10 --image-project=debian-cloud


######################################

Task 2. Create a Kubernetes service cluster

######################################


Create a zonal cluster using

gcloud container clusters create kuber1 --machine-type=n1-standard-1 --zone=us-west4-a



Use the Docker container hello-app

kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:2.0



Expose the app on port 

kubectl expose deployment hello-server --type=LoadBalancer --port 8080


 


Task 3: Setup an HTTP load balancer

 

Command-5)

cat << EOF > startup.sh

#! /bin/bash

apt-get update

apt-get install -y nginx

service nginx start

sed -i -- 's/nginx/Google Cloud Platform - '""\$HOSTNAME""'/' /var/www/html/index.nginx-debian.html

EOF

 

 

Create an instance template :

Command-6)

gcloud compute instance-templates create web-server-template \

          --metadata-from-file startup-script=startup.sh \

          --network nucleus-vpc \

          --machine-type g1-small \

          --region us-west3-b

(Important Note:-Replace us-west3-b with your zone mentioned in lab instructions)

 

Create a target pool :

Command-7)

gcloud compute target-pools create nginx-pool

 

Create a managed instance group :

Command-8)

gcloud compute instance-groups managed create web-server-group \

          --base-instance-name web-server \

          --size 2 \

          --template web-server-template \

          --region us-west3

(Important Note:-Replace us-west3 with your zone mentioned in lab instructions)

         

Create a firewall rule to allow traffic (80/tcp) :

Command-9)

gcloud compute firewall-rules create accept-tcp-rule-279 \

          --allow tcp:80 \

          --network nucleus-vpc

(Important Note:- Replace accept-tcp-rule-279 with the rule appears in your lab instructions)

 

 

Create a health check :

Command-10)

gcloud compute http-health-checks create http-basic-check

 

Command-11)

gcloud compute instance-groups managed \

          set-named-ports web-server-group \

          --named-ports http:80 \

          --region us-west3

(Important Note:-Replace us-west3 with your zone mentioned in lab instructions)

 

Create a backend service and attach the managed instance group :

Command-12)

gcloud compute backend-services create web-server-backend \

          --protocol HTTP \

          --http-health-checks http-basic-check \

          --global

 

Command-13)

gcloud compute backend-services add-backend web-server-backend \

          --instance-group web-server-group \

          --instance-group-region us-west3 \

          --global

 

(Important Note:-Replace us-west3 with your zone mentioned in lab instructions)

 

Create a URL map and target HTTP proxy to route requests to your URL map :

Command-14)

gcloud compute url-maps create web-server-map \

          --default-service web-server-backend

 

Command-16)

gcloud compute target-http-proxies create http-lb-proxy \

          --url-map web-server-map

 

Create a forwarding rule :

Command-17)

gcloud compute forwarding-rules create http-content-rule \

        --global \

        --target-http-proxy http-lb-proxy \

        --ports 80

 

Command-18)

gcloud compute forwarding-rules create accept-tcp-rule-279 \

        --global \

        --target-http-proxy http-lb-proxy \

        --ports 80

gcloud compute forwarding-rules list

 

(Important Note:- Replace accept-tcp-rule-279 with the rule appears in your lab instructions)

четвер, 14 лютого 2019 р.

КОРОТКО: ПЕРЕМИКАННЯ МОВИ ПО CTRL SHIFT І ПРОБЛЕМИ В UBUNTU 18.04

Як з'ясувалося при недовгому «гуглінні» проблема вже є на Launchpad.net (посилання) і вирішити її можна або вручну застосувавши патч , або скориставшись репозиторієм, який був створений користувачем Norbert. Цей варіант мені сподобався, так як він найбільш швидкий і я його застосував.


sudo add-apt-repository ppa:nrbrtx/xorg-hotkeys


sudo apt-get update
sudo apt-get dist-upgrade

Інший метод.

Встановити пакет dconf-editor і відредагувати один або обидва наступних ключа, щоб змусити все працювати: Перейти до org.gnome.desktop.wm.keybindings змініть джерело вхідного сигналу перемикача на ['< Alt> Shift_L '] Аналогічно, ключовий перемикач-вхід-джерело-назад зміниться на [' <Shift> Alt_L ']

Ще посилання

  • https://toster.ru/q/526950
  • https://bugs.launchpad.net/bugs/36812
  • https://bugs.launchpad.net/bugs/1245473
  • https://bugs.launchpad.net/bugs/1683383
  • https://launchpad.net/~nrbrtx/+archive/ubuntu/xorg-hotkeys
  • https://bugs.launchpad.net/ubuntu/+source/gnome-control-center/+bug/36812/comments/218
  • https://habr.com/post/87408/