Prerequisiti
- aver configurato correttamente kubectl usando il plugin kubectl-openstack
aver verificato che esista nel progetto CloudVeneto il security group K8S cosi' definito:
Egress | IPv4 | Any | Any | 0.0.0.0/0 |
Egress | IPv6 | Any | Any | ::/0 |
Ingress | IPv4 | ICMP | Any | 0.0.0.0/0 |
Ingress | IPv4 | TCP | 22 (SSH) | 0.0.0.0/0 |
Ingress | IPv4 | TCP | Any | 192.168.60.0/24 |
Ingress | IPv4 | UDP | Any | 192.168.60.0/24 |
Ingress | IPv4 | TCP | Any | 10.64.0.0/16 |
Ingress | IPv4 | UDP | Any | 10.64.0.0/16 |
Come creare un nuovo nodo
Per creare un nuovo nodo si usa kubectl, l'interfaccia standard di Kubernetes. Nello specifico il comando da utilizzare e' kubectl apply che richiede in input un file yaml.
...
Nel seguente esempio, si richiede la creazione di due nodi (osn-01 e osn-02), il primo di tipo shared ed il secondo private e con flavor diversi, rispettivamente cloudveneto.medium e cloudveneto.large. La chiave ssh (keypair) e' la stessa per entrambi (my_-key):
Code Block |
---|
language | yml |
---|
theme | Midnight |
---|
title | osnode.yml |
---|
|
---
apiVersion: osnode.infn.it/v1
kind: OpenStackNode
metadata:
name: osn-01
spec:
flavor: cloudveneto.medium
keyPair: my_-key
policy: shared
---
apiVersion: osnode.infn.it/v1
kind: OpenStackNode
metadata:
name: osn-02
spec:
flavor: cloudveneto.large
keyPair: my_-key
policy: private
|
Code Block |
---|
|
$ kubectl apply -f osnode.yml
openstacknode.osnode.infn.it/osn-01 created
openstacknode.osnode.infn.it/osn-02 created |
Come verificare lo stato di uno nodo o piu' nodi
Per verificare lo stato di un nodo si usa il comando kubectl get osn -o wide (l'opzione -o wide aggiunge informazioni relative alla VM):
Code Block |
---|
language | bash |
---|
theme | Midnight |
---|
|
$ kubectl get osn
NAME PHASE OWNER POLICY PROVIDER VM IPV4 AGE
osn-01 Running zangrand-at-infn.it private CloudVeneto 10.64.53.40 169m
osn-02 Running zangrand-at-infn.it shared CloudVeneto 10.64.53.67 169m
$ kubectl get osn -o wide
NAME PHASE OWNER POLICY PROVIDER VM FLAVOR VM STATUS VM IPV4 AGE
osn-01 Running zangrand-at-infn.it private CloudVeneto cloudveneto.medium ACTIVE 10.64.53.40 169m
osn-02 Running zangrand-at-infn.it shared CloudVeneto cloudveneto.medium ACTIVE 10.64.53.67 169m
$ kubectl get osn -o wide osn-01
NAME PHASE OWNER POLICY PROVIDER VM FLAVOR VM STATUS VM IPV4 AGE
osn-01 Running zangrand-at-infn.it private CloudVeneto cloudveneto.medium ACTIVE 10.64.53.40 169m |
Per avere una descrizione completa sullo stato di un nodo eseguire il comando kubectl describe osn:
Code Block |
---|
language | bash |
---|
theme | Midnight |
---|
|
$ kubectl describe osn osn-01
Name: osn-01
Namespace: glv
Labels: SECRET=bootstrap-token-t9d7lt
osn.infn.it/project-id=6dae634709c4478d92f70c388897fc96
osn.infn.it/project-name=GLV
osn.infn.it/user-id=2ddd446e119b417791492e950553a055
osn.infn.it/user-name=zangrand-at-infn.it
Annotations: <none>
API Version: osnode.infn.it/v1
Kind: OpenStackNode
Metadata:
Creation Timestamp: 2023-08-31T07:44:04Z
Finalizers:
openstacknode/finalizer
Generation: 2
Resource Version: 22448826
UID: da56df91-d78f-4547-b1ca-b4736cf8120b
Spec:
Availability Zone: nova
Flavor: cloudveneto.medium
Image:
Id:
Name:
Key Pair: Lisa
Policy: private
Provider: CloudVeneto
Region: regionOne
Security Groups:
K8S
User Data:
Status:
Created: 2023-08-31T07:47:05Z
Description: The node is running
Nodeid: osn-01-1693467852782
Phase: Running
Server:
Created: 2023-08-31T07:44:15Z
Id: f749c90f-844a-435c-848d-886f02cde706
ipv4: 10.64.53.40
Name: osn-01
Status: ACTIVE
Updated: 2023-08-31T10:37:05Z
Updated: 2023-08-31T10:37:05Z
Events: <none> |
Come rimuovere uno nodo o piu' nodi
Usa il comando kubectl delete osn per rimuovere uno o piu' nodi e le relative VM in CloudVeneto:
Code Block |
---|
language | bash |
---|
theme | Midnight |
---|
|
$ kubectl delete osn osn-01 osn-02
openstacknode.osnode.infn.it "osn-01" deleted
openstacknode.osnode.infn.it "osn-02" deleted |