CSE: Kubernetes mo te hunga kei vCloud

CSE: Kubernetes mo te hunga kei vCloud
Всем Привет!

Ko te mea i tupu ko ta matou roopu iti, ehara i te kii i tera tata nei, me te kore ohorere, kua tipu ki te neke etahi (me nga mea kei te heke mai katoa) hua ki Kubernetes.

He maha nga take mo tenei, engari ko ta matou korero ehara i te mea mo te holivar.

He iti noa ta matou whiriwhiri mo te turanga hanganga. vCloud Kaiwhakahaere me vCloud Kaiwhakahaere. I whiriwhiria e matou te mea hou ka whakatauhia kia timata.

Ka titiro ano ahau i roto i te "The Hard Way," I tino tere ahau ki te whakatau ko tetahi taputapu mo te whakaaunoa i nga tikanga taketake, penei i te tuku me te rahinga, i hiahiatia inanahi. Na te ruku hohonu ki roto a Google i whakaatu mai he hua penei i te VMware Container Service Extension (CSE) - he hua puna tuwhera e taea ai e koe te whakaaunoa i te hanga me te rahi o nga tautau k8s mo te hunga kei roto i te vCloud.

Whakakahoretanga: Kei a CSE ona here, engari mo o maatau kaupapa i tino tika. Ano hoki, me tautoko te otinga e te kaiwhakarato kapua, engari na te mea he tuwhera-puna ano te waahanga tūmau, patai ki to kaiwhakahaere tata kia waatea mai :)

Hei tiimata ki te whakamahi, me hiahia koe ki tetahi kaute kaiwhakahaere i roto i te whakahaere vCloud me te whatunga kua hangahia i mua mo te roopu (i te wa o te tukunga, me uru koe ki te Ipurangi mai i tenei whatunga, kaua e wareware ki te whirihora i te Firewall/NAT). Kare he aha te korero. I tenei tauira, me tango 10.0.240.0/24

CSE: Kubernetes mo te hunga kei vCloud

I muri i te hanganga, me whakahaere te roopu, ka tūtohu kia whai VPN me te ararere ki te whatunga i hangaia. Ka whakamahia e matou he SSL VPN paerewa kua whirihorahia ki te Edge Gateway o ta matou whakahaere.

I muri mai, me whakauru koe i te kiritaki CSE ki te waahi ka whakahaerehia nga huinga k8s. I roto i taku keehi, he pona mahi tenei me etahi ipu huna pai e rua e peia ana te aunoatanga.

Ka hiahia te kiritaki ki te putanga Python 3.7.3 me te teitei ake ka whakauruhia, ka whakauruhia te waahanga vcd-cli, na me whakauru e rua.

pip3 install vcd-cli

pip3 install container-service-extension

I muri i te whakaurunga, ka tirohia e matou te putanga CSE ka whiwhi i nga mea e whai ake nei:

# vcd cse version
Error: No such command "cse".

Karekau, engari ka taea te whakatika. Ko te tikanga, me hono a CSE hei kōwae ki te vcd-cli.
Hei mahi i tenei, me uru tuatahi koe ki te vcd-cli ki ta maatau whakahaere:

# vcd login MyCloud.provider.com org-dev admin
Password: 
admin logged in, org: 'org-dev', vdc: 'org-dev_vDC01'

I muri i tenei, ka hangaia e vcd-cli he konae whirihoranga ~/.vcd-cli/profiles.yaml
I te mutunga ka hiahia koe ki te taapiri i nga mea e whai ake nei:

extensions:
  - container_service_extension.client.cse

Na ka tirohia ano e matou:

# vcd cse version
CSE, Container Service Extension for VMware vCloud Director, version 2.5.0

Kua oti te wahanga whakaurunga a te kiritaki. Me ngana ki te tuku i te roopu tuatahi.
He maha nga huinga tawhā whakamahi a CSE, ka taea te tiro katoa konei.

Tuatahi, me hanga e tatou nga taviri mo te uru kore kupuhipa ki te kahui a meake nei. He mea nui tenei tohu, na te mea na te taunoa, ka whakakorehia te takiuru kupuhipa ki nga node, a, ki te kore koe e tautuhi i nga ki, ka nui te mahi ma nga miihini miihini mariko, kaore i te watea.

# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.

Me ngana ki te timata ki te hanga tautau:

vcd cse cluster create MyCluster --network k8s_cluster_net --ssh-key ~/.ssh/id_rsa.pub --nodes 3 --enable-nfs

Mena ka whiwhi tatou i te hapa Hapa: Kua pau te wātū, kāore rānei te kaiwhakamahi i takiuru. Tena koa takiuru ano. — takiuru ano ki te vcd-cli ki vCloud pera i te korero i runga ake nei ka ngana ano.

I tenei wa kua pai nga mea katoa, kua timata te mahi ki te hanga tautau.

cluster operation: Creating cluster vApp 'MyCluster' (38959587-54f4-4a49-8f2e-61c3a3e879e0) from template 'photon-v2_k8-1.12_weave-2.3.0' (revision 1)

Tata ki te 20 meneti hei whakaoti i te mahi; i tenei wa, me titiro ki nga tawhā whakarewatanga taketake.

—whatunga — te whatunga i hanga e matou i mua.
—ssh-key — nga mau taviri i hanga e matou, ka tuhia ki nga pokapu tautau
—nodes n — Te maha o nga pona Kaimahi i roto i te tautau. Ka kotahi tonu te rangatira, he herenga CSE tenei
—enable-nfs — hanga he node taapiri mo nga hea NFS i raro i nga pukapuka tohe. He iti noa te whiringa pedal; ka hoki ano tatou ki te whakatikatika i nga mahi a muri ake nei.

I tenei wa, i roto i te vCloud ka taea e koe te aro turuki i te hanganga o te tautau
CSE: Kubernetes mo te hunga kei vCloud

Kia oti te mahi o te hanga tautau, kua reri mo te whakamahi.

Kia tirohia te tika o te horahanga me te whakahau vcd cse cluster info MyCluster

CSE: Kubernetes mo te hunga kei vCloud

I muri mai me tiki te whirihoranga tautau hei whakamahi kubectl

# vcd cse cluster config MyCluster > ./.kube/config

A ka taea e koe te tirotiro i te mana o te tautau ma te whakamahi:

CSE: Kubernetes mo te hunga kei vCloud

I tenei wa, ka taea te whakaaro te tautau e mahi ana, ki te kore mo te korero me nga pukapuka e mau tonu ana. I te mea kei roto matou i te vCloud, kaore e taea e matou te whakamahi i te Kaiwhakarato vSphere. Kōwhiringa --whakahohe-nfs i hangaia hei whakaene i tenei whakararu, engari kaore i tino mahi. Me whakatikatika a-ringa.

Hei timata, me hanga e to tatou node he kōpae motuhake ki vCloud. Ma tenei e whakapumau ana ka kore o maatau raraunga e ngaro me te roopu mena ka mukua. Ano, hono te kōpae ki te NFS

# vcd disk create nfs-shares-1 100g --description 'Kubernetes NFS shares'
# vcd vapp attach mycluster nfsd-9604 nfs-shares-1

I muri i tera, ka haere matou ma te ssh (i hanga e koe nga taviri?) Ki to tatou NFS node ka mutu te hono i te kōpae:

root@nfsd-9604:~# parted /dev/sdb
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? yes
(parted) unit GB
(parted) mkpart primary 0 100
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End    Size   File system  Name     Flags
 1      0.00GB  100GB  100GB               primary

(parted) quit
root@nfsd-9604:~# mkfs -t ext4 /dev/sdb1
Creating filesystem with 24413696 4k blocks and 6111232 inodes
Filesystem UUID: 8622c0f5-4044-4ebf-95a5-0372256b34f0
Superblock backups stored on blocks:
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
	4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Waihangahia he whaiaronga mo nga raraunga ka whakairihia he waahanga hou ki reira:

mkdir /export
echo '/dev/sdb1  /export   ext4  defaults   0 0' >> /etc/fstab
mount -a

Me hanga e rima nga waahanga whakamatautau ka tohatoha mo te tautau:

>cd /export
>mkdir vol1 vol2 vol3 vol4 vol5
>vi /etc/exports
#Добавим это в конец файла
/export/vol1 *(rw,sync,no_root_squash,no_subtree_check)
/export/vol2 *(rw,sync,no_root_squash,no_subtree_check)
/export/vol3 *(rw,sync,no_root_squash,no_subtree_check)
/export/vol4 *(rw,sync,no_root_squash,no_subtree_check)
/export/vol5 *(rw,sync,no_root_squash,no_subtree_check)
#:wq! ;)
#Далее - экспортируем разделы
>exportfs -r

I muri i enei mahi makutu, ka taea e tatou te hanga PV me te PVC i roto i ta tatou kahui penei:
Kairīpoata:

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-vol1
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  nfs:
    # Same IP as the NFS host we ssh'ed to earlier.
    server: 10.150.200.22
    path: "/export/vol1"
EOF

Pvc:

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-pvc
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: ""
  resources:
    requests:
      storage: 10Gi
EOF

I konei ka mutu te korero mo te hanganga o te kahui kotahi, ka timata te korero mo tona huringa ora. Hei painga, e rua atu nga whakahau CSE whaihua e taea ai e koe te penapena rauemi i etahi wa, kaore ranei:

#Увеличиваем размер кластера до 8 воркер нод
>cse cluster resize MyCluster --network k8s_cluster_net --nodes 8

#Выводим ненужные ноды из кластера с их последующим удалением
>vcd cse node delete MyCluster node-1a2v node-6685 --yes

Nga mihi ki a koutou katoa mo to wa, mena he patai taau, patai ki roto i nga korero.

Source: will.com

Tāpiri i te kōrero