Google Cloud service account notes

Most of these notes were created from configuring the kube-cert-manager. setting up Google Cloud SDK (gcloud config) This first section touches upon configuring Google Cloud, the Google Cloud SDK, and the GKE cluster. Create an example project in Google Cloud, then configure your gcloud CLI: gcloud config configurations create EXAMPLE gcloud config set project EXAMPLE-123456 gcloud config set account youremail@example.org creating the GKE cluster With the Google Cloud account setup and the Google Cloud SDK installed and configured, Create a Kubernetes cluster.

Elasticsearch curl commands and references

A collection of Elasticsearch curl commands and references. Get Cluster Health cluster health: curl -s http://localhost:9200/_cluster/health?pretty Get indices indices: curl -s http://localhost:9200/_cat/indices Get shards shards: curl -s http://localhost:9200/_cat/shards Stuck Unassigned Shards Sometimes shards fail to assign and they hit a maximum retry. For example, say there’s a replica shard that is unassigned and won’t assign. Running this command has it retry: curl -s -XPOST 'localhost:9200/_cluster/reroute?retry_failed' -H 'Content-Type: application/json' -d' { "commands" : [ { "allocate_replica" : { "index" : "INDEXNAME", "shard" : 0, "node" : "NODENAME" } } ] } ' In the above example, INDEXNAME is the index, NODENAME is the node.

Ansible Jinja expressions

Use a default variable: # Sets the region variable to the value of "my_region" or defaults to 'us-east-1'. region: "{{ my_region | default('us-east-1') }}" # Sets the region variable to the value of "my_region" or defaults to whatever "your_region" is. region: "{{ my_region | default(your_region) }}" Convert an Ansible variable to an integer and increment it. # convert to an integer and increase by 1. # this is a string, not an integer string: "3" # this will equal 4.

Kubernetes kubectl commands

A collection of kubectl commands that are handy. ~/.kube/config Here’s the Kubernetes config. Note that I believe that minikube creates this on creation: apiVersion: v1 clusters: - cluster: certificate-authority: /Users/USERNAME/.minikube/ca.crt server: https://192.168.99.100:8443 name: minikube contexts: - context: cluster: minikube user: minikube name: minikube current-context: minikube kind: Config preferences: {} users: - name: minikube user: client-certificate: /Users/USERNAME/.minikube/apiserver.crt client-key: /Users/USERNAME/.minikube/apiserver.key commands Get pods in wide view (shows what nodes they’re running on): kubectl get pods --all-namespaces -o wide Get Kubernetes nodes labels: kubectl get nodes --show-labels Remove all pods from a node: kubectl drain ip-10-1-1-2.

sed notes and examples

The Unix command sed and some examples that I’ve used. sed cheatsheat : # label = # line_number a # append_text_to_stdout_after_flush b # branch_unconditional c # range_change d # pattern_delete_top/cycle D # pattern_ltrunc(line+nl)_top/cycle g # pattern=hold G # pattern+=nl+hold h # hold=pattern H # hold+=nl+pattern i # insert_text_to_stdout_now l # pattern_list n # pattern_flush=nextline_continue N # pattern+=nl+nextline p # pattern_print P # pattern_first_line_print q # flush_quit r # append_file_to_stdout_after_flush s # substitute t # branch_on_substitute w # append_pattern_to_file_now x # swap_pattern_and_hold y # transform_chars sed examples # grabs an SSH fingerprint (aka, using ssh-keyscan or the AWS System Log).

some ansible variables

ec2_facts # These are the instance local ec2_facts keys. "ansible_facts" "ansible_ec2_ami_id" "ansible_ec2_ami_launch_index" "ansible_ec2_ami_manifest_path" "ansible_ec2_block_device_mapping_ami" "ansible_ec2_block_device_mapping_ephemeral0" "ansible_ec2_block_device_mapping_ephemeral1" "ansible_ec2_block_device_mapping_root" "ansible_ec2_hostname" "ansible_ec2_iam_info" "ansible_ec2_iam_security_credentials_demo_etcd_role" "ansible_ec2_instance_action" "ansible_ec2_instance_id" "ansible_ec2_instance_type" "ansible_ec2_local_hostname" "ansible_ec2_local_ipv4" "ansible_ec2_mac" "ansible_ec2_metrics_vhostmd" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_device_number" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_interface_id" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_local_hostname" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_local_ipv4s" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_mac" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_owner_id" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_security_group_ids" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_security_groups" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_subnet_id" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_subnet_ipv4_cidr_block" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_vpc_id" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_vpc_ipv4_cidr_block" "ansible_ec2_network_interfaces_macs_12_20_32_7f_db_7a_vpc_ipv4_cidr_blocks" "ansible_ec2_placement_availability_zone" "ansible_ec2_placement_region" "ansible_ec2_profile" "ansible_ec2_public_key" "ansible_ec2_reservation_id" "ansible_ec2_security_groups" "ansible_ec2_services_domain" "ansible_ec2_services_partition" "ansible_ec2_user_data" ec2_remote_facts # These are the ec2_remote_facts keys. "instances" "ami_launch_index" "architecture" "block_device_mapping" "attach_time" "delete_on_termination" "device_name" "status" "volume_id" "client_token" "ebs_optimized" "groups" "id" "name" "hypervisor" "id" "image_id" "instance_profile" "arn" "id" "interfaces" "id" "mac_address" "kernel" "key_name" "launch_time" "monitoring_state" "persistent" "placement" "tenancy" "zone" "private_dns_name" "private_ip_address" "public_dns_name" "public_ip_address" "ramdisk" "region" "requester_id" "root_device_type" "source_destination_check" "spot_instance_request_id" "state" "tags" "Environment" "Name" "Role" "sshUser" "terraform_id" "virtualization_type" "vpc_id" "ami_launch_index" "architecture" "block_device_mapping" "attach_time" "delete_on_termination" "device_name" "status" "volume_id" "client_token" "ebs_optimized" "groups" "id" "name" "hypervisor" "id" "image_id" "instance_profile" "arn" "id" "interfaces" "id" "mac_address" "kernel" "key_name" "launch_time" "monitoring_state" "persistent" "placement" "tenancy" "zone" "private_dns_name" "private_ip_address" "public_dns_name" "public_ip_address" "ramdisk" "region" "requester_id" "root_device_type" "source_destination_check" "spot_instance_request_id" "state" "tags" "Environment" "Name" "Role" "sshUser" "terraform_id" "virtualization_type" "vpc_id" Get a variable from another hosts "{{< hostvars['127.

Terraform and Azure Resource Manager

This was originally going to be a post on deploying infrastructure using Terraform and Azure Resource Manager. Didn’t quite pan out. Here are the notes. originally, this was going to be a few sections Creating and configuring Azure to work with Terraform. Terraforming a Azure resource group using Azure Resource Manager (ARM). Configuring a base image. Using Terraform and Ansible to deploy an infrastructure. This first section is about configuring Azure to work with Terraform.

Terraform and creating a base image in Azure Resource Manager

This blog post was originally stretched out into a few sections. It never came into fruition. Leaving this here as a reference for anyone else trying similar things. Creating and configuring Azure to work with Terraform. Terraforming a Azure resource group using Azure Resource Manager (ARM). Configuring a base image. Using Terraform and Ansible to deploy an infrastructure. This second section deals with using Terraform and configuring a base image, for future use.