Line Notify – Useful!

Since I use Line, using Line Notify is an easy solution to send myself messages. Here’s how it works:

  1. Go to https://notify-bot.line.me/my/ and generate a token.
  2. Use cURL to send a message:
curl -X POST -H 'Authorization: Bearer YOUR_TOKEN' \
-F 'message=A message from myself to myself.' \
-F 'stickerPackageId=1' \
-F 'stickerId=15' \
-F 'imageFile=@ttgo-eight.jpg' \
https://notify-api.line.me/api/notify

See the API for Line Notify for more details incl. the list of stickers.

Here an example using Node.js:

const fs = require('fs');
const fetch = require("node-fetch");
const FormData = require('form-data');

const params = new FormData();
params.append('message', 'Test via Node.js');
params.append('stickerPackageId', '1');
params.append('stickerId', '15');
params.append('imageFile', fs.createReadStream('ttgo-eight.jpg'));

try {
    fetch('https://notify-api.line.me/api/notify', {
        method: 'POST',
        headers: {
            'Authorization': 'Bearer YOUR_TOKEN'
        },
        redirect: 'follow',
        body: params
    })
        .then(res => res.json())
        .then(json => console.log(json));
} catch (e) {
    console.error(`Error: ${e}`);
}

Docker Volume Backup

Doing a backup of volumes is simple if you know the command:

docker run --volumes-from influxdb \
-v $(pwd)/backup:/backup -i -t ubuntu \
tar cfvj /backup/influxdb.tar.bz2 /var/lib/influxdb

influxdb is the stopped container. /var/lib/influxdb is where the (only) volume is mounted. ~/backup/ is where I’d like the compressed tar backup file.

Grafana Alerts

So far I did not have to bother about alerts. InfluxDB collects stats (via API or telegraf) and I can watch it via Grafana. Today I wanted alerts.

First you have to create notification channels in Grafana: Alerting/Notification Channels.

Email

Since I use Gmail, this section in grafana.ini works:

##### SMTP / Emailing #####
[smtp]
enabled = true
host = smtp.gmail.com:587
user = MY_EMAIL_ADDRESS@gmail.com
password = MY_16_CHARACTER_PASSWORD
from_address = MY_EMAIL_ADDRESS@gmail.com
from_name = GrafanaAlerts

The only tricky part is the password which is an application specific password you create at https://myaccount.google.com/security under “App Passwords”.

Line

If you use Line, this works:

Installing HashiCorp’s Vault

HashiCorp Vault Icon

Trying to use Vault at work to keep secrets in there. However knowing not much about it makes me want to test it at home first.

Installing on k8s seemed most sensible since I already have 3 node k3s cluster. Since k3s does support Helm v3 and Vault can be installed via Helm v3 charts, that’s what I did.

Installing

See https://www.vaultproject.io/docs/platform/k8s/helm.html, but in short:

$ helm repo add hashicorp https://helm.releases.hashicorp.com
"hashicorp" has been added to your repositories
$ helm install vault hashicorp/vault

Initialize and Unseal

Initialize is a one-time action. Unsealing is always needed when you restart Vault. See https://learn.hashicorp.com/tutorials/vault/kubernetes-minikube. Short summary:

# Initialize and get the keys
$ kubectl exec vault-0 -- vault operator init -key-shares=1 -key-threshold=1 -format=json > cluster-keys.json

# Unseal
$ VAULT_UNSEAL_KEY=$(cat cluster-keys.json | jq -r ".unseal_keys_b64[]")
$ kubectl exec vault-0 -- vault operator unseal $VAULT_UNSEAL_KEY

# Show pod status
$ kubectl get pods -l app.kubernetes.io/name=vault
NAME      READY   STATUS    RESTARTS   AGE
vault-0   1/1     Running   2          16h

# Show Vault status
$ kubectl exec vault-0 -- vault status
Key             Value
---             -----
Seal Type       shamir
Initialized     true
Sealed          false
Total Shares    1
Threshold       1
Version         1.5.2
Cluster Name    vault-cluster-f6c361da
Cluster ID      a757fd57-3032-59ec-d03a-4ad0556536ea
HA Enabled      false

The important part is: the Vault pod(s) run and it’s Sealed=False.

Visiting Hokkaido During COVID-19

Lake Mashu

Just came back from a 5 day trip through Hokkaido. Here my observations regarding COVID-19:

  1. Definitely less tourists, but not empty either. Lots of cars from Sapporo, so a lot of tourists are from Hokkaido and traveling within their (large) prefecture.
  2. Every hotel, restaurant and shop had hand disinfectant at their entrance. Everyone’s using it.
  3. Every hotel had those at elevators too since you touch the elevator buttons.
  4. Every hotel and most museum checked your forehead temperature.
  5. Every hotel and many museum asked for your address so they could trace back who was here when someone is found out to have COVID-19.
  6. Where there are seats and tables, about half was unavailable.
  7. Lots of places had announcement of them disinfecting surfaces on a regular basis (tables, rails, generally things you touch). And often you could see that happening when you stay long enough.
  8. For buffet type food, you get one-time gloves to pick up your food. Everything is neatly laid out so you can grab one thing without touching more (e.g. cutlery).
  9. Almost everyone wears masks. Correctly too. 100% inside buildings (excl. places where you eat or drink, or in public baths), and I’d say 80% outside too. Depends a bit on the chances to be near to someone else. The more people in less space, the more you approach 100%, but if it’s all empty with >5m distances between groups, it’s more like 50% mask wearer. It’s hot after all and the masks do not help.
  10. In the airplane, everyone had a mask. Nothing stupid happening like this.
  11. Boarding and leaving the plane was well organized in groups to minimize the time to stand around in close proximity. First the window seats at the back of the plane, then the middle seats, then the aisle. Then repeat for the front half. Leaving was slightly different: first the front 10 rows, then the next 10 rows etc.
    I hope they keep this method.

In summary: Everyone certainly did what was doable to prevent anyone getting any disease via touch or droplets.

Unrelated to COVID-19, but interesting nonetheless:

  1. The weather is so much nicer than in Tokyo: not only much cooler (28 vs 35°C), but also much less humid. Also there’s generally wind.
  2. Sunshine is still strong though, so you’ll get sunburn. Ask me how I know…
  3. It starts to be Autumn in Hokkaido! Leaves are starting to change colors.
  4. Roads are often very straight.
  5. We saw plenty wild animals: deer crossing roads, deer eating grass, foxes watching cars. I only got one photo though:
  6. The airplane we used between Tokyo and Hokkaido were both fully booked.

Summary

Hokkaido is beautiful if you like nature. There’s so much of it. Use a car to travel as it’s hard to get to many places otherwise.

k3s – Half Size k8s

Followed https://rancher.com/docs/k3s/latest/en/ and it’s great. Took me a while to be able to access the dashboard though.

How to connect to the dashboard

What made this part work:

How to connect the normal way

To connect the “normal” way via https://giga.lan:8443 do this: After installing it (see https://rancher.com/docs/k3s/latest/en/installation/kube-dashboard/) the trick was to expose it via the LoadBalancer:

❯ kubectl expose deployment kubernetes-dashboard --type=LoadBalancer --name=dash --namespace=kubernetes-dashboard
❯ kubectl get services --namespace=kubernetes-dashboard

NAME                        TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)          AGE
kubernetes-dashboard        ClusterIP      10.43.193.11    <none>          443/TCP          22h
dashboard-metrics-scraper   ClusterIP      10.43.122.142   <none>          8000/TCP         22h
dash                        LoadBalancer   10.43.164.78    192.168.21.39   8443:31610/TCP   3m36s

Instead of the expose command you can also do:

❯ cat dashboard-service.yaml
apiVersion: v1
kind: Service
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: dash
  namespace: kubernetes-dashboard
spec:
  ports:
  - protocol: TCP
    port: 8443
    targetPort: 8443
  selector:
    k8s-app: kubernetes-dashboard
  type: LoadBalancer
❯ kubectl apply -f dashboard-service.yaml

And now I can access the dashboard from anywhere via https://giga.lan:8443

Disabling Waking up Computer via Mouse

My Linux machine keeps on waking up someone moves the mouse. Or kicks the table. While it’ll go back to sleep eventually, I’d rather not have it awake unless I want to use it.

Disabling mouse events to wake up your computer is surprisingly simple. The thing to know is /proc/acpi/wakeup:

❯ cat /proc/acpi/wakeup
Device  S-state   Status   Sysfs node
GPP0      S4    *disabled
GPP1      S4    *enabled   pci:0000:00:01.2
GPP2      S4    *disabled
GPP3      S4    *disabled
GPP4      S4    *enabled   pci:0000:00:01.5
GPP5      S4    *enabled   pci:0000:00:01.6
GPP6      S4    *disabled
GP17      S4    *enabled   pci:0000:00:08.1
XHC0      S3    *enabled   pci:0000:04:00.3
XHC1      S3    *enabled   pci:0000:04:00.4
GP18      S4    *enabled   pci:0000:00:08.2
SIO1      S3    *disabled  pnp:00:03

XHCx is the USB 3 controller which is where the mouse is connected to. Turn off via

echo "XHC0" >/proc/acpi/wakeup
echo "XHC1" >/proc/acpi/wakeup

and that’s it! To make it persistent put this into /etc/rc.local and make sure it runs during power-up.

Note

Running the echo command again will simply change between disabled and enabled.

More Bicycle Fixing

The rear gear changing shift level I had broke partially. Downshifting was fine. Upshifting worked except I had to manually push the lever into its original position in order to change another gear up. Root cause was the steel spring to reset that lever rusted away.

Replacing it with a new one like this was surprisingly cheap and quick: 1900 Yen, about 15 minutes work.

I’m getting the hang of fixing my bike!

Summer in Japan

Summer in Japan has one drawback. Actually there are 3: it’s hot and humid. And cockroaches like that.

According to this article, there’s a new thing out which seems to work very well. Having studied chemistry, I was naturally curious what it’s active ingredient is.

Here is the product page from the manufacturer. The back of the product packaging shows the ingredients:

d.d-T Cyphenothrin it is.

Here the Wikipedia article. Very short. Has one reference to a PubMed.gov article. I knew cockroaches are pretty sturdy, but this was new to me:

Resistance to organophosphorous and carbamate insecticides amongst German cockroaches is widely reported.

Tilak, R; Agrawal, VK; Dutta, J (2005). “Field performance of cyphenothrin: An integrated insecticide strategy against German cockroaches (Dictyoptera: Blatellidae)”. Journal of Vector Borne Diseases. 42 (2): 68–73. PMID 16161703.

To get a lot more details, have a look here from PubChem.

Important data points:

  • Very toxic for aquatic life
  • LD50 (rat) via oral: 318mg/kg, so for an average human (70kg), eating 22g has 50% chance of killing your (assuming the toxicity is same for rats and humans)
  • LD50 via skin is way higher

And here I found the d.d-T part:

TL;DR: I’ll buy one to test it out. I won’t drink it and I’ll be careful to not get this into water.

Fixing my Bicycle

While riding my bike a while ago, the bottom bracket gear cable guide broke. I got a generic replacement which looked similar enough. Made by Shimano. For about 350 Yen. Awesome! What could go wrong?

Turns out a lot: the diameter it’s made for is smaller than the one needed for my bicycle. And the included screw has a different thread than the existing one. And there’s an extra plastic alignment knob. So it seems those bottom bracket gear cable guides are not all the same. Well, live and learn.

However not all is lost! I still have the original screw and it fits into the screw hole of the new cable guide. The alignment knob I could easily cut off with a chisel. The plastic used is thermoplastic, to heating it up a bit makes it bend enough to fit. The cable for the front derailleur would (just) rub against the aluminium frame, so a piece of UHMWPE adhesive tape fixes that.

I replaced the complete gear cables. They were rusty although that seems to not matter much. The new cable with the new housing is smoother though. Without a dedicated cable cutter, I used my Dremel to cut the housing. That’s a tough piece of housing!

Adjusting the derailleurs was easier than I expected. It’s smoother now than it was before, although I cannot say why: could be the cleaning of the chain and other moving parts, or the adjusted derailleurs, or the new cables.

I also replaced the front break pads. I guess 14 years is a good time to replace them. The new ones I got work very well. Quieter and breaking better. I’ll replace the one in the back too, and maybe the complete brakes as they are rusty enough to worry me a bit.

Summary: Total costs of parts: about 4000 Yen. Tools I had to buy: mainly a bicycle stand (3500 Yen). Got a torque wrench, although I did not need it in the end.

Create your website at WordPress.com
Get started