Consul add remove node: различия между версиями
Материал из noname.com.ua
Перейти к навигацииПерейти к поискуSirmax (обсуждение | вклад) |
Sirmax (обсуждение | вклад) |
||
(не показано 12 промежуточных версий этого же участника) | |||
Строка 1: | Строка 1: | ||
+ | [[Категория:Linux]] |
||
+ | [[Категория:Consul]] |
||
+ | [[Категория:Hashicorp]] |
||
+ | [[Категория:Заготовка]] |
||
+ | |||
=Consul Remove node and add new again= |
=Consul Remove node and add new again= |
||
Строка 28: | Строка 33: | ||
− | ==Instance group |
+ | ==Instance group== |
<PRE> |
<PRE> |
||
gcloud compute instance-groups unmanaged list-instances consul-ig |
gcloud compute instance-groups unmanaged list-instances consul-ig |
||
Строка 51: | Строка 56: | ||
==Create instance== |
==Create instance== |
||
<PRE> |
<PRE> |
||
− | gcloud compute instances |
+ | gcloud compute instances \ |
create consul-tf-2 \ |
create consul-tf-2 \ |
||
+ | --tags=consul-tf \ |
||
+ | --machine-type=n1-standard-1 \ |
||
+ | --zone=us-central1-c \ |
||
+ | --subnet=kohl-ecom-nonprod-network01 \ |
||
+ | --private-network-ip=10.206.249.132 \ |
||
+ | --image=consul-v1 \ |
||
+ | --image-project=kohls-ecom-nonprod \ |
||
+ | --no-address |
||
+ | </PRE> |
||
− | --tags=consul-tf |
||
− | --machine-type=n1-standard-1 |
||
− | --zone=us-central1-c |
||
− | --subnet=kohl-ecom-nonprod-network01 |
||
− | --private-network-ip= |
||
+ | <PRE> |
||
+ | gcloud compute instances \ |
||
+ | create consul-tf-1 \ |
||
+ | --tags=consul-tf \ |
||
+ | --machine-type=n1-standard-1 \ |
||
+ | --zone=us-central1-f \ |
||
+ | --subnet=kohl-ecom-nonprod-network01 \ |
||
+ | --private-network-ip=10.206.249.131 \ |
||
+ | --image=consul-v1 \ |
||
+ | --image-project=kohls-ecom-nonprod \ |
||
+ | --no-address |
||
</PRE> |
</PRE> |
||
+ | |||
− | gcloud compute instances create NAMES [NAMES …] |
||
+ | ==Instance Groups== |
||
− | [--no-boot-disk-auto-delete] [--boot-disk-device-name=BOOT_DISK_DEVICE_NAME] [--boot-disk-size=BOOT_DISK_SIZE] [--boot-disk-type=BOOT_DISK_TYPE] [--can-ip-forward] [--csek-key-file=FILE] [--custom-cpu=CUSTOM_CPU] [--custom-memory=CUSTOM_MEMORY] [--description=DESCRIPTION] [--disk=[auto-delete=AUTO-DELETE],[boot=BOOT],[device-name=DEVICE-NAME],[mode=MODE],[name=NAME]] [--image-project=IMAGE_PROJECT] [--local-ssd=[device-name=DEVICE-NAME],[interface=INTERFACE]] [--machine-type=MACHINE_TYPE] [--maintenance-policy=MAINTENANCE_POLICY] [--metadata=KEY=VALUE,[KEY=VALUE,…]] [--metadata-from-file=KEY=LOCAL_FILE_PATH,[KEY=LOCAL_FILE_PATH,…]] [--network=NETWORK] [--preemptible] [--private-network-ip=PRIVATE_NETWORK_IP] [--no-require-csek-key-create] [--no-restart-on-failure] [--subnet=SUBNET] [--tags=TAG,[TAG,…]] [--zone=ZONE] [--address=ADDRESS | --no-address] [--image=IMAGE | --image-family=IMAGE_FAMILY] [--no-scopes | --scopes=[SCOPE,…]] [--no-service-account | --service-account=SERVICE_ACCOUNT] [GLOBAL-FLAG …] |
||
+ | <PRE> |
||
+ | gcloud compute \ |
||
+ | instance-groups unmanaged \ |
||
+ | create consul-1-ig --zone us-central1-f |
||
+ | </PRE> |
||
+ | |||
+ | <PRE> |
||
+ | gcloud compute \ |
||
+ | instance-groups unmanaged \ |
||
+ | create consul-2-ig --zone us-central1-c |
||
+ | </PRE> |
||
+ | |||
+ | <PRE> |
||
+ | gcloud compute \ |
||
+ | instance-groups unmanaged \ |
||
+ | add-instances consul-1-ig \ |
||
+ | --instances \ |
||
+ | consul-tf-1 \ |
||
+ | --zone us-central1-f |
||
+ | </PRE> |
||
+ | |||
+ | <PRE> |
||
+ | gcloud compute \ |
||
+ | instance-groups unmanaged \ |
||
+ | add-instances consul-2-ig \ |
||
+ | --instances \ |
||
+ | consul-tf-2 \ |
||
+ | --zone us-central1-c |
||
+ | </PRE> |
||
+ | |||
+ | |||
+ | <PRE> |
||
+ | gcloud compute \ |
||
+ | instance-groups set-named-ports consul-1-ig \ |
||
+ | --named-ports "consul-8300:8300,consul-8301:8301,consul-8302:8302,consul-8400:8400,consul-8500:8500,consul-8600:8600" \ |
||
+ | --zone us-central1-f |
||
+ | </PRE> |
||
+ | |||
+ | |||
+ | <PRE> |
||
+ | gcloud compute \ |
||
+ | instance-groups set-named-ports consul-2-ig \ |
||
+ | --named-ports "consul-8300:8300,consul-8301:8301,consul-8302:8302,consul-8400:8400,consul-8500:8500,consul-8600:8600" \ |
||
+ | --zone us-central1-c |
||
+ | </PRE> |
||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==Backend Service== |
||
+ | <PRE> |
||
+ | gcloud compute \ |
||
+ | backend-services add-backend consul-backend-service \ |
||
+ | --instance-group consul-1-ig \ |
||
+ | --instance-group-zone us-central1-f \ |
||
+ | --region us-central1 |
||
+ | </PRE> |
||
+ | |||
+ | |||
+ | <PRE> |
||
+ | gcloud compute \ |
||
+ | backend-services add-backend consul-backend-service \ |
||
+ | --instance-group consul-2-ig \ |
||
+ | --instance-group-zone us-central1-c \ |
||
+ | --region us-central1 |
||
+ | </PRE> |
Текущая версия на 08:38, 30 октября 2023
Consul Remove node and add new again
Current State
# consul members Node Address Status Type Build Protocol DC consul-tf-0 10.206.249.130:8301 alive server 0.7.4 2 dc1 consul-tf-1 10.206.249.131:8301 alive server 0.7.4 2 dc1 consul-tf-2 10.206.249.132:8301 alive server 0.7.4 2 dc1
Remove one node
# consul leave Graceful leave complete
# consul members Error connecting to Consul agent: dial tcp 127.0.0.1:8400: getsockopt: connection refused
# consul members Node Address Status Type Build Protocol DC consul-tf-0 10.206.249.130:8301 alive server 0.7.4 2 dc1 consul-tf-1 10.206.249.131:8301 alive server 0.7.4 2 dc1 consul-tf-2 10.206.249.132:8301 left server 0.7.4 2 dc1
Instance group
gcloud compute instance-groups unmanaged list-instances consul-ig NAME STATUS consul-tf-0 RUNNING consul-tf-1 RUNNING consul-tf-2 RUNNING
gcloud compute instance-groups unmanaged remove-instances consul-ig --instances=consul-tf-2 Updated [https://www.googleapis.com/compute/v1/projects/kohls-ecom-nonprod/zones/us-central1-b/instanceGroups/consul-ig].
gcloud compute instance-groups unmanaged list-instances consul-ig NAME STATUS consul-tf-0 RUNNING consul-tf-1 RUNNING
Create instance
gcloud compute instances \ create consul-tf-2 \ --tags=consul-tf \ --machine-type=n1-standard-1 \ --zone=us-central1-c \ --subnet=kohl-ecom-nonprod-network01 \ --private-network-ip=10.206.249.132 \ --image=consul-v1 \ --image-project=kohls-ecom-nonprod \ --no-address
gcloud compute instances \ create consul-tf-1 \ --tags=consul-tf \ --machine-type=n1-standard-1 \ --zone=us-central1-f \ --subnet=kohl-ecom-nonprod-network01 \ --private-network-ip=10.206.249.131 \ --image=consul-v1 \ --image-project=kohls-ecom-nonprod \ --no-address
Instance Groups
gcloud compute \ instance-groups unmanaged \ create consul-1-ig --zone us-central1-f
gcloud compute \ instance-groups unmanaged \ create consul-2-ig --zone us-central1-c
gcloud compute \ instance-groups unmanaged \ add-instances consul-1-ig \ --instances \ consul-tf-1 \ --zone us-central1-f
gcloud compute \ instance-groups unmanaged \ add-instances consul-2-ig \ --instances \ consul-tf-2 \ --zone us-central1-c
gcloud compute \ instance-groups set-named-ports consul-1-ig \ --named-ports "consul-8300:8300,consul-8301:8301,consul-8302:8302,consul-8400:8400,consul-8500:8500,consul-8600:8600" \ --zone us-central1-f
gcloud compute \ instance-groups set-named-ports consul-2-ig \ --named-ports "consul-8300:8300,consul-8301:8301,consul-8302:8302,consul-8400:8400,consul-8500:8500,consul-8600:8600" \ --zone us-central1-c
Backend Service
gcloud compute \ backend-services add-backend consul-backend-service \ --instance-group consul-1-ig \ --instance-group-zone us-central1-f \ --region us-central1
gcloud compute \ backend-services add-backend consul-backend-service \ --instance-group consul-2-ig \ --instance-group-zone us-central1-c \ --region us-central1