Port forward Elasticsearch Head to Kubernetes Statefulset

If you prefer Elasticsearch Head to oversee cluster-wide operations but miss having it installed on-cluster (now that it is not available ES v5 and above) plus run Elasticsearch as a Kubernetes Statefulset, then you can run Elasticsearch Head as a Chrome plugin and port forward to the Statefulset.

This assumes that you have installed Elasticsearch in a standard way such as via the Elastic Helm chart, and that you have a Statefulset with Pods named elasticsearch-n and a Service named elasticsearch pointing to the Statefulset.

If you then point Elasticsearch Head at localhost:9200 (which is the default) it will port forward to your Kubernetes cluster and the overview should populate.

Clone a private GitHub repository without an SSH key using a Personal Access Token

If you need to clone a private GitHub repository without an SSH key you can use a Personal Access Token. This can be useful in a build/deployment pipeline for example where you are using a programmatic GitHub user to clone into a temporary server or container. You can then pass the token and other information via environment variables.

Iterate over set for resource using count and index in Terraform

Even in Terraform 0.12 you cannot use iteration with resources, so you may still have to resort to using count to create multiple resources.

However you cannot iterate over a set (unlike a list) normally because it has no indices. Luckily Terraform will convert sets to lists without modifying the order of items, which allows you to use count and index as you would with a list.

CentOS/RHEL 6 Python PIP error, SyntaxError: invalid syntax {str(c.version) for c in all_candidates}

If you’re attempting to upgrade the version of PIP on CentOS or RHEL 6 from the default 7.1.0 to a newer version, as of April 14th 2018 when PIP 10.0.0 was released you will run into issues since EL6 ships with Python 2.6 as standard. Since you cannot upgrade the default version of Python because it will break in-built tooling such as Yum, you’ll need to version lock PIP when you upgrade it to 9.0.3. This is the last stable version of PIP that is compatible with Python 2.6

Setup remote interpreter (virtualenv) in VM or container for PyCharm

If you are developing with a virtual machine or container, any modules installed by PIP will either be installed globally or potentially in a virtualenv location outside of the project root. Therefore you will need to tell PyCharm that the imported modules you’re using are located remotely, not locally.

First you will need to go into Preferences/Settings and to the Project specific settings, then into the Interpreter section.

You will then be able to add a Remote Interpreter, which will be the credentials required to log into your VM or container via SSH by PyCharm.

If you are using Vagrant then the location of the SSH key that can be used to login to the VM can be found by using the vagrant ssh-config command, which will output something like this.

The location of the SSH key used by the vagrant ssh command is by the IdentityFile key.

Allow connection to PostgreSQL server outside localhost

If PostgreSQL is set to only listen and allow connections from localhost (127.0.0.1) then you can change the configuration to allow other or all IP addresses to connect.

First we will need to make sure PostgreSQL is listening for connections outside of local networking in the main configuration, which should be located somewhere such as /etc/postgresql/9.x/main/postgresql.conf (where 9.x is whichever version you have installed) so just uncomment the listen addresses line

However to make sure that the IP address you’re connecting from is also allowed you’ll need to change /etc/postgresql/9.x/main/pg_hba.conf to either add each IP address or set it to all (0.0.0.0)

Depending on your operating system you will need to restart the PostgreSQL server (for example service postgresql restart)

How to reset/change expired MySQL 5.6 password in Homestead

MySQL 5.6 introduced password expiration, so the password on your Homestead Virtual Machine may expire at some point.

SQLSTATE[HY000] [1862] Your password has expired. 
To log in you must change it using a client that supports 
expired passwords.

To change this you will need to log into MySQL running on Homestead in order to change your password to fix the expiry

vagrant ssh
mysql -u homestead -psecret

If you try and execute most commands you will be greeted with

ERROR 1820 (HY000): You must reset your password using 
ALTER USER statement before executing this statement.

Confusingly you can’t run the ALTER USER statement until you’ve changed your password… so you need to use SET PASSWORD

SET PASSWORD = PASSWORD('new_password');

https://dev.mysql.com/doc/refman/5.6/en/alter-user.html

Port forward http 80 and https 443 to 8080 or 8443 for Vagrant on Mac OS X

Assuming you have a Vagrantfile setup to forward port 8080 and/or 8443 to the default http and https ports on the web server running in the Vagrant Virtual Machine guest, you can forward these ports to the normally reserved ports on your Mac OS X host

Create a port forwarding rule for both http and https ports that forwards 80 to 8080 and 443 to 8443 on your Mac (thanks to Abe Tobing for his guide on using pf)

Add port forwarding configuration that references this rule

Once you have created both these files, to activate this rule run “sudo pfctl -ef /etc/pf-vagrant.conf”

 

Older posts