I have a requirement in which i have to stop instance group during night hours and then restart in the morning. Is there anyway I can stop instance group for few hours. From console i can change autoscaling to off and set number of instances to 0 but i cant find this option from the API. Please suggest
You can use:
gcloud compute instance-groups managed stop-autoscaling NAME [--zone ZONE]
and
gcloud compute instance-groups managed set-autoscaling NAME \
--max-num-replicas MAX_NUM_REPLICAS [--zone ZONE]
Note that stop-autoscaling will not bring down the number of instances to 0 for you, you need set-autoscaling --max-num-replicas.
The corresponding REST API is InstanceGroupManagers: resize.
Related
When I creating a map in Zabbix, I can't track the total traffic between two hosts. I have a signature:
Arista2→Raidix2
↓{10.253.0.19:ifHCInOctets.["19"].last(0)} + {10.253.0.19:ifHCInOctets.["20"].last(0)}
{10.253.0.19:ifHCOutOctets.["19"].last(0)} + {10.253.0.19:ifHCOutOctets.["20"].last(0)}↑
Where is the plus sign I need to add these two traffic into one. I looked at the documentation and didn't find anything. I need your help guys.
enter image description here
Good day,
Using SGE 8.6.18, I get correct output with qconf -sq q#hostname.fqdn...com
I want to change the qtype of the queue with the -mq option as qconf -sq q#hostname.fqdn...com but I get this error:
Cluster queue entry "q#hostname.fqdn...com" does not exist
I checked the output of qconf -sm and I am listed as a manager of the farm.
Thanks for any guidance.
The 'does not exist' simply means there is no individual queue, for each machine. I found out there is only on queue, named 'q'. Therefore I must use qconf -mq q.
Currently, I'm creating a disk from a snapshot. Then I wait for 60 seconds and create an instance which will use that disk as its system disk. I'm using the gcloud utility for this.
Is there any way I can create the disk and the instance in one command?
Mix of copy-pasted Python code and pseudocode below:
cmd_create_disk = [GCLOUD, 'compute', 'disks', 'create', new_instance,
'--source-snapshot', GCE_RENDER_SNAPSHOT_VERSION,
'--zone', GCE_REGION, '--project', GCE_PROJECT]
# wait for 60 seconds
cmd_make_instance = [GCLOUD, 'compute', 'instances', 'create', new_instance,
'--disk', 'name='+new_instance+',boot=yes,auto-delete=yes',
'--machine-type', instance_type, '--network', GCE_NETWORK,
'--no-address', '--tags', 'render', '--tags', 'vpn',
'--tags', proj_tag, '--zone', GCE_REGION,
'--project', GCE_PROJECT]
The instance uses the disk as its system disk. Waiting for 60 seconds is quite arbitrary and I'd rather leave this up to GCE, making sure the instance is indeed started with the system disk.
When you delete an instance you can specify that the disk should also get deleted. In the same manner, I'd like to create an instance and specify the disk to be created from image.
The boot disk can be created automatically. You can specify the image to use for that using --image and --image-project flags in gcloud compute instances create command line. You'll need to make sure to create the image first though - your current command to create the disk seems to use a snapshot rather than an image.
With the gcloud command line tool I can do:
$ gcloud compute instances list --filter='tags.items:development'
The documentation claims: "..you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values." But no examples are provided, so it's not clear how one actually goes about this.
I've tried labels.development eq *.*, labels eq *development*, labels:development et al.. I've also tried setting the verbosity of the of the command line client to info and looking through the output, as well as monitoring requests that go to the API from the Compute Engine web console, but neither has gotten me anywhere.
Finding Tags with regular expression filters
I'm struggling with the same issue but I think that regular expressions solve the problem.
I have many instances with multiple tags but I can search across all tags with the '~' operator e.g. to find all servers with the production tag:
gcloud compute instances list --filter='tags.items~^production$'
For many servers the 'production' tag is the third entry in tags.items yet the regexp finds it.
This seems to work but I can't find any documentation that specifically says that it should work. The nearest is the section on topic filters which mentions this
key ~ value True if key matches the RE (regular expression) pattern
value.
You can also search for multiple tags
gcloud compute instances list --filter='tags.items~^production$ AND tags.items~^european$'
which would find all servers with the two tags 'production' and 'european'
Tags v Custom metadata
If you want something a bit more flexible than tags (which can only be present or missing), you can attach your own custom multi-valued metadata to an instance (via the UI, command-line or API). You can then search for particular values of that item.
For example suppose I have different instances supporting eCommerce for different brands, I could attach a custom 'brand' metadata item to each server and then find all of the servers which run my "Coca-Cola" brands via ..
gcloud compute instances list --filter="metadata.items.key['brand']['value']='Coca-Cola'"
... and my 'Pepsi Cola' servers with ...
gcloud compute instances list --filter="metadata.items.key['brand']['value']='Pepsi Cola'"
Finding Metadata with regular expression filters
You probably guessed this already but the regular expression operator also works with metadata filters so you can do
gcloud compute instances list --filter="metadata.items.key['brand']['value']~'Cola'"
As explained here you can use the following syntax using gcloud cli:
gcloud compute instances list --filter labels.env=dev
Multi Filtering example that I'm using:
gcloud compute instances list --filter="zone:( europe-west1-d )" --filter="name:( testvm )" --filter labels.group=devops --filter labels.environment_type=production
Add instance metadata MyKey=MyValue for gke-cluster-asia-eas-default-pool-dc8f484c-knbs:
gcloud compute instances add-metadata gke-cluster-asia-eas-default-pool-dc8f484c-knbs --metadata=MyKey=MyValue
Display all instances with MyKey=MyValue:
gcloud compute instances list --filter="metadata.items.key['MyKey'][value]='MyValue'"
Display all instances that belong to the cluster cluster-asia-east1-a:
gcloud compute instances list --filter="metadata.items.key['cluster-name'][value]='cluster-asia-east1-a'"
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
gke-cluster-asia-eas-default-pool-dc8f484c-knbs asia-east1-a n1-standard-1 10.140.0.2 104.155.227.25 RUNNING
gke-cluster-asia-eas-default-pool-dc8f484c-x8cv asia-east1-a n1-standard-1 10.140.0.3 104.199.226.16 RUNNING
gke-cluster-asia-eas-default-pool-dc8f484c-z5wv asia-east1-a n1-standard-1 10.140.0.4 104.199.134.9 RUNNING
I'm creating instance on the Google Compute Engine with jclouds, using the command:
Template template = context.getComputeService().templateBuilder().imageId("debian-7-wheezy-v20150710").build();
Set<? extends NodeMetadata> listNode = context.getComputeService().createNodesInGroup("teste", 1, template);
But is the error below:
2015-08-16 07:27:04 INFO compute:64 - Image debian-7-wheezy-v20150710 not found in the image cache. Trying to get it from the provider...
Exception in thread "main" java.util.NoSuchElementException: imageId(debian-7-wheezy-v20150710) not found
at org.jclouds.compute.domain.internal.TemplateBuilderImpl.throwNoSuchElementExceptionAfterLoggingImageIds(TemplateBuilderImpl.java:764)
at org.jclouds.compute.domain.internal.TemplateBuilderImpl.findImageWithId(TemplateBuilderImpl.java:745)
at org.jclouds.compute.domain.internal.TemplateBuilderImpl.build(TemplateBuilderImpl.java:688)
at br.com.clouddeploy.main.TestGoogle.main(TestGoogle.java:47)
Any suggestion?
If you are using imageId() you probably need to use the full path to the image. Here's how to find it:
% gcloud compute images list --uri | grep debian-7
shows:
https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20150710
https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20150710
So you can use either of these. The one that starts with backports has newer versions of packages, but is still based on Debian 7 Wheezy.
Alternatively, it looks like jclouds has the ability to do this URL creation on its own, but instead of using imageId(), you should use (see GitHub code example):
ComputeService compute = initComputeService(account, credentials);
[...]
TemplateBuilder templateBuilder = compute.templateBuilder();
templateBuilder.fromImage(compute
.getImage("debian-7-wheezy-v20140408"));