本資料は、CNDT2021「Kubernetesオペレータのアンチパターン&ベストプラクティス」の補足資料です。
プレゼンの中では説明しきれなかったベストプラクティスの実装を詳細に解説します。
プレゼンでも紹介したように、必ず現在の状態をチェックしてから実行すべき処理を決定することになります。
| #!/usr/bin/env bash | |
| # usage: git sy | |
| set -e | |
| # run に渡されたコマンドを実行しつつ、コマンドの名前をログに出力する | |
| run() { | |
| echo -e "\e[1m+$@\e[0m" | |
| "$@" | |
| } |
| #!/bin/bash | |
| # Small utility function based on yq to extract openAPIV3Schema from CRD | |
| # example: crd2jsonschema.sh ./crd-alertmanager.yaml | |
| set -e | |
| function crd2jsonschema() { | |
| set -e | |
| local xkgroup="x-kubernetes-group-version-kind" | |
| local document="$1" | |
| local openAPIV3Schema=$(mktemp -u) |
sysctlで設定可能な項目について調査した内容。
| BLOCK_DOMAINS_FILE = "/etc/unbound/block_domains.txt" | |
| block_domains = set() | |
| def load_file(file_name): | |
| try: | |
| with open(file_name, "r") as f: | |
| for line in f: | |
| block_domains.add(line.rstrip()) | |
| except IOError: | |
| log_info("pythonmod: failed to load %s" % file_name) |
| [Unit] | |
| Description=Keep reverse portforward tunnel | |
| After=network.target | |
| [Service] | |
| User=root | |
| Restart=always | |
| RestartSec=5 | |
| Type=simple | |
| ExecStart=/usr/bin/ssh -NTv \ |
| package main | |
| import ( | |
| "errors" | |
| "fmt" | |
| "sync" | |
| "time" | |
| ) | |
| type GroupWaiter struct { |
| #!/bin/sh | |
| ### | |
| # SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer) | |
| # For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos | |
| ### | |
| # Alot of these configs have been taken from the various places | |
| # on the web, most from here | |
| # https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx |