Skip to content

Instantly share code, notes, and snippets.

View frankmanzhu's full-sized avatar

Frank Zhu frankmanzhu

  • Sydney
View GitHub Profile
@frankmanzhu
frankmanzhu / gist:f77adb298cd3e7af688a236089e50d29
Created June 2, 2017 03:35
Change network card back to eth0
Just after the Ubuntu 16.04 installation, I came to know that the network interface name got changed to ens33 from old school eth0. If you ever interested in changing interface names to old type ethX, here is the tutorial for you.
As you can see in the following command, my system is having a network adapter called ens33.
Note: This is just the case of VMware environment, it may vary depends on the hardware but the steps to get back ethX will be the same.
$ ip a
1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
port=0
interface=enp0s3
dhcp-range=192.168.56.100,192.168.56.200,12h
dhcp-option=option:router,192.168.56.1
dhcp-authoritative
# enable logging
log-queries
@frankmanzhu
frankmanzhu / gist:9fe6ac5b51916c1fd6410f70c1c61f21
Last active March 13, 2019 04:38
Install RancherOS on VirtualBox and configure it for ssh access
Run ssh-keygen
echo -e "#cloud-config\nssh_authorized_keys:\n - $(cat .ssh/id_rsa.pub)" > $HOME/cloud-config.yml
After boot rancherOS
sudo scp frank@xxx:/home/frank/cloud-config.yml .
sudo ros install -d /dev/sda -c cloud-config.yml
@frankmanzhu
frankmanzhu / gist:78f0d2912f3ddf73dc19fd1d48bf251c
Created May 19, 2017 00:04
Ansible Missing sudo password
Ansible file
- name: config /etc/hosts for the cluster
become: true
blockinfile:
block: "{{ lookup('file', '/home/hosts') }}"
dest: "/etc/hosts"
marker: "# {mark} ANSIBLE MANAGED BLOCK "
backup: yes
@frankmanzhu
frankmanzhu / kafka
Created April 11, 2017 04:12
kafka YML
version: "3"
services:
kafka1:
image: wurstmeister/kafka:latest
environment:
KAFKA_LISTENERS: PLAINTEXT://:9092
KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
KAFKA_HEAP_OPTS: "-Xmx512m -Xms512m"
version: "3"
services:
zoo1:
image: zookeeper:latest
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=0.0.0.0:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
networks:
@frankmanzhu
frankmanzhu / setup coreos
Last active April 11, 2017 04:10
setup coreos
//su root
sudo su
//list device
lsblk
//Create a cloud-config file
sudo openssl passwd -1 > cloud-config-file
@frankmanzhu
frankmanzhu / gist:c4c004415bf675cb6cc167b1c999cccb
Last active April 11, 2017 04:09
Enable the remote API on a new socket
Enable the remote API on a new socket
Create a file called /etc/systemd/system/docker-tcp.socket to make Docker available on a TCP socket on port 2375.
[Unit]
Description=Docker Socket for the API
[Socket]
ListenStream=2375
BindIPv6Only=both
@frankmanzhu
frankmanzhu / docker-cleanup-resources.md
Created March 30, 2017 03:08 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@frankmanzhu
frankmanzhu / gist:f55f63989bc5dd6ad04fa836308a2e0b
Created March 23, 2017 23:26
Docker compose doing blue green deployment
I just worked out another flow to have Zero downtime (mainly for web apps).
Proxy
We use jwilder/nginx-proxy to handle routing to app servers, this will assist us in dynamically routing requests to services.
First Deploy
For the first deploy run docker-compose --project-name=app-0001 up -d.
Rolling Update
We edit the docker-compose.yml with the new image id and run docker-compose --project-name=app-0002 up -d. We now have version 0.2 of the app up and running. The load balancer will already begin routing requests, and given we are using nginx LB we will have 0 downtime.