作成日: 2021/08/10
0

terraform

terraform taintで、指定したリソースを再作成する事ができる

$ terraform taint esxi_guest.test01
Resource instance esxi_guest.test01 has been marked as tainted.

$ terraform apply -auto-approve
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # esxi_guest.test01 is tainted, so must be replaced
-/+ resource "esxi_guest" "test01" {
      ~ guest_shutdown_timeout = 20 -> (known after apply)
      ~ guest_startup_timeout  = 120 -> (known after apply)
      ~ guestos                = "otherlinux-64" -> (known after apply)
      ~ id                     = "421" -> (known after apply)
      ~ ip_address             = "192.168.100.7" -> (known after apply)
      + notes                  = (known after apply)
      ~ ovf_properties_timer   = 0 -> (known after apply)
      ~ virthwver              = "9" -> (known after apply)
        # (10 unchanged attributes hidden)

      ~ network_interfaces {
          ~ nic_type        = "e1000" -> (known after apply)
            # (2 unchanged attributes hidden)
        }
      ~ network_interfaces {
          ~ nic_type        = "e1000" -> (known after apply)
            # (2 unchanged attributes hidden)
        }
    }

Plan: 1 to add, 0 to change, 1 to destroy.

Command: taint - Terraform by HashiCorp

Terraform職人入門: 日々の運用で学んだ知見を淡々とまとめる - Qiita

terraform workspaceで、ワークスペースを操作する事ができる。
ワークスペースを分ける事で、それぞれのstateを保持する事ができる。(ただし、本番とステージングのような分け方は推奨されていない)

yukihisa@macbook-pro ~/.g/g/y/h/terraform (main)> terraform workspace -h
Usage: terraform [global options] workspace

  new, list, show, select and delete Terraform workspaces.

Subcommands:
    delete    Delete a workspace
    list      List Workspaces
    new       Create a new workspace
    select    Select a workspace
    show      Show the name of the current workspace

Terraform Workspacesの基礎と使い方について考えてみた! #AdventCalendar | DevelopersIO

kubernetes

PVC

  • StorageClassでreclaimPolicy: Retainに設定しておけば、PVCを削除してもPVは残る
    • 再度PVCを作成すると、他のPVが作成されてしまう → どうやって紐付けするか

kubeadm

CPU

root@k8s-master1:~# cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 166
model name	: Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz
stepping	: 0
microcode	: 0xca
cpu MHz		: 1608.000
cache size	: 12288 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 22
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm 3dnowprefetch cpuid_fault ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase smep arat md_clear flush_l1d arch_capabilities
bugs		: spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit
bogomips	: 3216.00
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management:

root@k8s-master01:~# fgrep 'processor' /proc/c
puinfo | wc -l                                
1

kubeadm initを実行します。

root@k8s-master1:~# kubeadm init --node-name k8s-master --pod-network-cidr=10.244.0.0/16
[init] Using Kubernetes version: v1.21.1
[preflight] Running pre-flight checks
	[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
	[WARNING Hostname]: hostname "k8s-master" could not be reached
	[WARNING Hostname]: hostname "k8s-master": lookup k8s-master on 127.0.0.53:53: server misbehaving
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
root@k8s-master1:~#

--ignore-preflight-errors=NumCPUオプションをつけるとインストールできます。他にも、今回は発生しませんでしたが、メモリ不足などのエラーの同様のオプションでスキップする事が可能です。(非推奨)

root@k8s-master1:~# kubeadm init --node-name master --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=NumCPU
[init] Using Kubernetes version: v1.21.1
[preflight] Running pre-flight checks
	[WARNING NumCPU]: the number of available CPUs 1 is less than the required 2
	[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
	[WARNING Hostname]: hostname "master" could not be reached
	[WARNING Hostname]: hostname "master": lookup master on 127.0.0.53:53: server misbehaving
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'

[memo] Linux で CPU の数を調べる - Qiita

Mac

command + control + スペースキー」で絵文字が使える 🔥🔥🔥

【Mac】絵文字キーボードを表示させるショートカットキー – 和洋風KAI

Vagrant

Vagrant box vmware/esxi - Vagrant Cloud

vmware/esxi という Vagrant Box を使って virtualbox で VM を起動しようとした時にエラーが発生しました。

$ cat Vagrantfile 
Vagrant.configure("2") do |config|
  config.vm.box = "vmware/esxi"
end

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'vmware/esxi' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'vmware/esxi'
    default: URL: https://vagrantcloud.com/vmware/esxi
The box you're attempting to add doesn't support the provider
you requested. Please find an alternate box or use an alternate
provider. Double-check your requested provider to verify you didn't
simply misspell it.

If you're adding a box from HashiCorp's Vagrant Cloud, make sure the box is
released.

Name: vmware/esxi
Address: https://vagrantcloud.com/vmware/esxi
Requested provider: [:virtualbox]

Box をよくみてみると、vmware_desktop しか対応していないため、virtualbox では動作させる事ができませんでした。

Linux

iptables 設定例

kubernetes master node

# common
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 80 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 443 -j ACCEPT

sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 6443 -j ACCEPT

# etcd
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 2376 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 2379 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 2380 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -p udp --dport 8472 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 9099 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 10250 -j ACCEPT

sudo netfilter-persistent save

Go

gotour インストール

A Tour of Goの通り

$ go tool tour
go tool: no such tool "tour"

上記がエラーになったので、以下を試しました。

$ go get github.com/atotto/go-tour-jp/gotour
$ gotour
golang.org/x/tour/gotour has moved to golang.org/x/tour

上記もうまく動きませんでした。

$ go get golang.org/x/tour
can't load package: package golang.org/x/tour: no Go files in /Users/yumenotayume/go/src/golang.org/x/tour

Reference

  • [[入門][Go]Goに入門してみた | codelikeなブログ](

インフラエンジニアです。 メモで利用しています。まとまったら以下に移行予定です。 Zenn: https://zenn.dev/ymmmtym 個人ブログ: https://blog.ymmmtym.com/ Scrapbox:https://scrapbox.io/yumenomatayume/