機雷がなんだ! 全速前進!

SEというかプログラマというか、日々のエンジニア生活の中で体験したことなどを中心に書き残しています。

M4 MacBook Airを自分用にカスタマイズした際の作業記録

前回の記事で記載したごご高齢MacBook Airだが対応OSが既にサポ切れ(macOS Big Sur:2024年末まで)したことで、使っていたGoogle Chrome ブラウザなどのサポートも打ち切られてしまったようです。もうしばらくはオモチャとしては使えそうですが、スペックもさることながらバッテリーの持ちもかなり悪くなっているので、流石に世代交代せねばということで、新しいM4チップのMacBook Airに乗り換えることにしました。

いったん自分好みに諸々カスタマイズしたのですが、とある事情で再初期化するハメになってしまい、何をどうカスタムしたか思い出すのがなかなかの苦痛でした。再々初期化するようなことはもう無いと思います(そう願いたいです)が、また同じ苦痛を味わわないための精神的な保険としてここに作業記録を書き残しておきます。

デバイス

対象のデバイスは以下のとおりです。

基本方針

当たり前のことではありますが、インストールしたアプリの管理をしやすくするため可能な限りコマンドベースのパッケージ管理ツール(Homebrew)を使ってインストールしました。

設定内容

ランチャー:Raycast

公式:Raycast - Your shortcut to everything

Homebrew:raycast — Homebrew Formulae

備考:デフォルトのランチャー Spotlight の代わりに使用する(Command + Space)

【↓】競合を避けるためデフォルト設定はチェックを外しておく

 

マウス設定:Mac Mouse Fix

公式:Mac Mouse Fix

Homebrew:mac-mouse-fix — Homebrew Formulae

備考:5ボタンマウス(M-XGM10BBB)ホイール設定(縦スクロール反転+拡大縮小)

【↓】マウスボタン設定はチェックを外す(ブラウザBack+Forwardを利用するため)

※これまでお世話になった Scroll Reverser とはサヨナラ👋しました

 

キーボード設定:Karabiner-Elements

公式:Karabiner-Elements

Homebrew:karabiner-elements — Homebrew Formulae

備考:外部キーボード(JIS配列)のキーマッピング変更

【↓】外部キーボード(JIS配列)の場合はキーを入れ替える(Command ↔︎ Space)

 

ターミナル:iTerm2

公式:iTerm2 - macOS Terminal Replacement

Homebrew:iterm2 — Homebrew Formulae

備考:これを機に WARP にしようか迷ったが一旦使い慣れてるツールを継続利用する

 

ターミナル入力補完:zsh-completions

公式:GitHub - zsh-users/zsh-completions: Additional completion definitions for Zsh.

Homebrew:zsh-completions — Homebrew Formulae

備考:インストール指示通り ~/.zshrc を修正して再読込すると警告が出るので

% source ~/.zshrc
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]? y

以下のコマンドで原因のパスを特定して

% compaudit
There are insecure directories:
/opt/homebrew/share

パーミッションを変更する必要がある

% chmod -R go-w /opt/homebrew/share

その後、再度 ~/.zshrc を再読込する

 

Appleメニュー設定:MenuMate

公式:なし

Homebrew:なし

Mac App Store:「MenuMate」をMac App Storeで

備考:大きな外部ディスプレイでAppleメニューまでの移動を省略する(マウスのホイールボタンのクリックで呼び出せるよう設定)

 

スクショ画像編集:Monosnap

公式:Monosnap

Homebrew:なし

Mac App Store:「Monosnap - screenshot editor」をMac App Storeで

備考:外部キーボード(JIS配列)の配置をWindowsと同じにしておく

 

さいごに

このメモを書いていて、マウスとキーボードを外した時、つまり、ラップトップ単体で使いやすい状態になっているのか、という確認をしていないことに気付きました。おそらく、ここに記載した設定だけだと不都合が出る気がします。なんとなくトラックパッドを含むマウスまわりは大丈夫だと思うのですが、キーボード設定まわりがとても怪しいです。後日、ラップトップ単体での動作確認と設定のチューニングもすることになりそうですが、もう疲れたので今日はこんなところにしておきます…😓お疲れ様でした。

ご高齢MacBook AirにPython3をセットアップしたときのメモ

気付けばもう軽く10年以上使っているMacBook Air (13-inch, Mid 2013)でちょっと遊んでみようとPython3をセットアップしようとしたら意外と面倒だったので作業記録を残しておくことにします。

デイバス

  • モデル:MacBook Air (13-inch, Mid 2013)

  • 機種ID:MacBookAir6,2

  • 最終対応のオペレーティングシステム:macOS Big Sur(※2024年末でサポ切れ🥺)

  • 技術仕様:MacBook Air(13-inch, Mid 2013)

作業記録

Homebrewば現時点での最新バージョンまで上げました。

mba:~$ brew --version
Homebrew 4.5.2
Homebrew/homebrew-core (git revision c5976bed6c1; last commit 2025-05-11)
Homebrew/homebrew-cask (git revision 2e4492a5808; last commit 2025-05-11)

pythonは、もはやいつインストールしたか覚えてない古いのが入ってました。

mba:~$ python --version
Python 2.7.16(2021年7月15日サポ切れ)

ということでpython3をセットアップします。

mba:~$ brew install python3
python@3.13 3.7.5 is already installed but outdated (so it will be upgraded).
Warning: You are using macOS 11.
We (and Apple) do not provide support for this old version.

This is a Tier 3 configuration:
  https://docs.brew.sh/Support-Tiers#tier-3
Do not report any issues to Homebrew/* repositories!
Read the above document instead before opening any issues or PRs.

==> Fetching dependencies for python@3.13: mpdecimal, ca-certificates, openssl@3, readline, sqlite, xz, pkgconf, lzip and expat
==> Fetching mpdecimal
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/m/mpdecimal.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.1.tar.gz
##################################################################################################################################################################################################### 100.0%
==> Fetching ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2025-02-25
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:8f46fb05f753f80f2bc398c0a24b10d680bd77d496e2b931de0b61998e37aebc
##################################################################################################################################################################################################### 100.0%
==> Fetching openssl@3
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/o/openssl@3.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://github.com/openssl/openssl/releases/download/openssl-3.5.0/openssl-3.5.0.tar.gz
==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/7634677/2eea5d52-f337-454f-ba38-2e866f5994e0?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseasse
##################################################################################################################################################################################################### 100.0%
==> Fetching readline
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/r/readline.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-001
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-002
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-003
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-004
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-005
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-006
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-007
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-008
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-009
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-010
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-011
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-012
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-013
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz
##################################################################################################################################################################################################### 100.0%
==> Fetching sqlite
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/s/sqlite.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://www.sqlite.org/2025/sqlite-autoconf-3490200.tar.gz
##################################################################################################################################################################################################### 100.0%
==> Fetching xz
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/x/xz.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1.tar.gz
==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/553665726/b4e0a8ab-1ca0-4700-96c0-5f40d8f0ae89?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseas
##################################################################################################################################################################################################### 100.0%
==> Fetching pkgconf
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/p/pkgconf.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://distfiles.ariadne.space/pkgconf/pkgconf-2.4.3.tar.xz
##################################################################################################################################################################################################### 100.0%
==> Fetching lzip
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/l/lzip.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://download-mirror.savannah.gnu.org/releases/lzip/lzip-1.25.tar.gz
##################################################################################################################################################################################################### 100.0%
==> Fetching expat
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/e/expat.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.lz
==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/80314213/8620f79a-521e-43fa-a280-ea2239b0c167?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseass
##################################################################################################################################################################################################### 100.0%
==> Installing python@3.13 dependency: lzip
Error: Your Xcode (10.1) at /Applications/Xcode.app is too outdated.
Please update to Xcode 13.2.1 (or delete it).
Xcode can be updated from the App Store.

Error: Xcode alone is not sufficient on Big Sur.
Install the Command Line Tools:
  xcode-select --install

はい、エラー(x2)です。各個撃破していきます。

まずはXcodeから。

言われたとおりXcodeをバージョンアップしたいのですが、残念ながら古くなったXcode 13.2.1はApp Storeからはもう取得できないようなのでAppleのDeveloperサイトダウンロードページから該当バージョンのものを探してインストールする必要があります。

巨大なファイル(10.01 GB)なのでダウンロードも解凍もすごく時間がかかります。気長に作業しましょう。

次は指示どおりコマンドラインツールを実行してインストールします。

mba:~$ xcode-select --install
xcode-select: note: install requested for command line developer tools

ここまで完了したらPython3インストールをリトライします。

mba:~$ brew install python3
Error: You have not agreed to the Xcode license. Please resolve this by running:
  sudo xcodebuild -license accept

おっと、またエラーです。

指示通り先ほどインストールしたXcode 13.2.1のライセンスのアクセプトを完了させます。

mba:~$ sudo xcodebuild -license accept
Password:●●●●●●

気を取り直してPython3インストールを再リトライします。

mba:~$ brew install python3
==> Downloading https://formulae.brew.sh/api/formula.jws.json
==> Downloading https://formulae.brew.sh/api/cask.jws.json
python@3.13 3.7.5 is already installed but outdated (so it will be upgraded).
Warning: You are using macOS 11.
We (and Apple) do not provide support for this old version.

This is a Tier 3 configuration:
  https://docs.brew.sh/Support-Tiers#tier-3
Do not report any issues to Homebrew/* repositories!
Read the above document instead before opening any issues or PRs.

==> Fetching dependencies for python@3.13: mpdecimal, ca-certificates, openssl@3, readline, sqlite, xz, pkgconf, lzip and expat
==> Fetching mpdecimal
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c537a72ca9e5af8a2922b2f0b8083b543582c9cb/Formula/m/mpdecimal.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.1.tar.gz
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/de81d45d656755dc758aa95bb88e99cc95bd3c0bbc7c3fc6c852576f4e5b01cc--mpdecimal-4.0.1.tar.gz
==> Fetching ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2025-02-25
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/6c1debb525d4dc6007afae4cd2b772105111632b22fc28506550f6dfe27c6d52--ca-certificates-2025-02-25.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:8f46fb05f753f80f2bc398c0a24b10d680bd77d496e2b931de0b61998e37aebc
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/50c52ec06796c09a75e7a9484e6db3205765a935a486322e3795612fd23b405e--ca-certificates--2025-02-25.all.bottle.tar.gz
==> Fetching openssl@3
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c537a72ca9e5af8a2922b2f0b8083b543582c9cb/Formula/o/openssl@3.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://github.com/openssl/openssl/releases/download/openssl-3.5.0/openssl-3.5.0.tar.gz
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/7671fc790a3b588e6d502fc00d334cdb86d8c677cf4358323cc3e7648cf4241d--openssl-3.5.0.tar.gz
==> Fetching readline
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c537a72ca9e5af8a2922b2f0b8083b543582c9cb/Formula/r/readline.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-001
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/8f4cd1b000569d71bbb49566dc53fa3774e04f9f8829402ea2ee8283d0fe04a1--readline82-001
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-002
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/0d6e5043bc5aef4dc90cfc70625aeb16e7ac3f0b921750ff655b29bccfedfbea--readline82-002
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-003
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/02b4ff2dcede6771ffd73279413faa777ba4682446ba6a79bb9e8a71d8b03caf--readline82-003
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-004
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/fc9301ab2f04d3aeda625c18007a69fb1ab37a4d45813bd9baec7745a78c6ab9--readline82-004
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-005
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/00a0b8f3cb3bafa66c11534e34123ae5b53eb2653015f60b2266be17cba95ea1--readline82-005
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-006
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/b4e6cfe4609276d4eda1987b1b83e2cf22ec013baf9c8c95eac7c3fcf295a750--readline82-006
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-007
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/323518491bffe6a24bbe7d91c888eff86cf90d6803bc77bda99b165cf6218d18--readline82-007
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-008
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/626d12f6255507a2d06a29e60b09ac0005a8a7c22dabfa04a456e4e293713bb0--readline82-008
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-009
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/25c999bb7a8df4cd2037958483901f2a595e1a2c0668cbc033ddb3e251df8223--readline82-009
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-010
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/ca913fa24988bb1f278b2de32d3a830f2ff79564944e19c214c2f3492ba549a4--readline82-010
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-011
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/1d69210897bc6b911e6fe25cb19e7073b36d121100fe19528fae9490fad05013--readline82-011
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-012
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/9ad62b844fe8cfb5f3fa6c425fb9f4e78a471a172e5973be7dea349d8bfe1c33--readline82-012
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-013
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/ba00d79322014c18925b3ca3e306d0c37acbff6e2ceb199e2a752c468f8da54f--readline82-013
==> Downloading https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/36ad701a297ee809015add3ddd50c365157d54017e6bec9668d61b0b3382daf3--readline-8.2.tar.gz
==> Fetching sqlite
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c537a72ca9e5af8a2922b2f0b8083b543582c9cb/Formula/s/sqlite.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://www.sqlite.org/2025/sqlite-autoconf-3490200.tar.gz
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/eea37f6ef8bb993e015a4d0e0aca0a4c859e99deccb58f8f8e36f27a383f76f7--sqlite-autoconf-3490200.tar.gz
==> Fetching xz
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c537a72ca9e5af8a2922b2f0b8083b543582c9cb/Formula/x/xz.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1.tar.gz
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/f716b14a72b232f1726d651f8710fc1286738f58673b8a8ed70c34674e0a06e2--xz-5.8.1.tar.gz
==> Fetching pkgconf
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c537a72ca9e5af8a2922b2f0b8083b543582c9cb/Formula/p/pkgconf.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://distfiles.ariadne.space/pkgconf/pkgconf-2.4.3.tar.xz
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/d4f63c2624e72b785c96c8ab998eff9dbad8f874a1edbead950eb7ba67875384--pkgconf-2.4.3.tar.xz
==> Fetching lzip
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c537a72ca9e5af8a2922b2f0b8083b543582c9cb/Formula/l/lzip.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://download-mirror.savannah.gnu.org/releases/lzip/lzip-1.25.tar.gz
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/01b3ba1475fe67700ae14a0a2841dd12eafcf0f4296a050a1d6ba20ca31f7ffd--lzip-1.25.tar.gz
==> Fetching expat
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c537a72ca9e5af8a2922b2f0b8083b543582c9cb/Formula/e/expat.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.lz
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/a40a44a47be31067cd2e8504e0e38e3c6316275564e12eec602fb8e4c79110f3--expat-2.7.1.tar.lz
==> Installing python@3.13 dependency: lzip
==> ./configure CXX=clang++ CXXFLAGS=
==> make check
==> make install
🍺  /usr/local/Cellar/lzip/1.25: 11 files, 233.6KB, built in 1 minute 14 seconds
==> Fetching dependencies for python@3.13: mpdecimal, openssl@3, readline, sqlite, xz, pkgconf and expat
==> Fetching python@3.13
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/c537a72ca9e5af8a2922b2f0b8083b543582c9cb/Formula/p/python@3.13.rb
##################################################################################################################################################################################################### 100.0%
==> Downloading https://raw.githubusercontent.com/Homebrew/formula-patches/8b5bcbb262d1ea4e572bba55043bf7d2341a6821/python/3.13-sysconfig.diff
##################################################################################################################################################################################################### 100.0%
==> Downloading https://files.pythonhosted.org/packages/69/59/b6fc2188dfc7ea4f936cd12b49d707f66a1cb7a1d2c16172963534db741b/flit_core-3.12.0.tar.gz
##################################################################################################################################################################################################### 100.0%
==> Downloading https://files.pythonhosted.org/packages/70/53/b309b4a497b09655cb7e07088966881a57d082f48ac3cb54ea729fd2c6cf/pip-25.0.1.tar.gz
##################################################################################################################################################################################################### 100.0%
==> Downloading https://files.pythonhosted.org/packages/a9/5a/0db4da3bc908df06e5efae42b44e75c81dd52716e10192ff36d0c1c8e379/setuptools-78.1.0.tar.gz
##################################################################################################################################################################################################### 100.0%
==> Downloading https://files.pythonhosted.org/packages/8a/98/2d9906746cdc6a6ef809ae6338005b3f21bb568bea3165cfc6a243fdc25c/wheel-0.45.1.tar.gz
##################################################################################################################################################################################################### 100.0%
==> Downloading https://www.python.org/ftp/python/3.13.3/Python-3.13.3.tgz
##################################################################################################################################################################################################### 100.0%
==> Upgrading python3
  -> 3.13.3
==> Installing dependencies for python@3.13: pkgconf, mpdecimal, ca-certificates, openssl@3, readline, sqlite, xz and expat
==> Installing python@3.13 dependency: pkgconf
==> ./configure --disable-silent-rules --with-pkg-config-dir=/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/11 --with-system-i
==> make
==> make install
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pkg-config
Target /usr/local/bin/pkg-config
is a symlink belonging to pkg-config. You can unlink it:
  brew unlink pkg-config

To force the link and overwrite all conflicting files:
  brew link --overwrite pkgconf

To list all files that would be deleted:
  brew link --overwrite pkgconf --dry-run

Possible conflicting files are:
/usr/local/bin/pkg-config -> /usr/local/Cellar/pkg-config/0.28/bin/pkg-config
/usr/local/share/aclocal/pkg.m4 -> /usr/local/Cellar/pkg-config/0.28/share/aclocal/pkg.m4
/usr/local/share/man/man1/pkg-config.1 -> /usr/local/Cellar/pkg-config/0.28/share/man/man1/pkg-config.1
==> Summary
🍺  /usr/local/Cellar/pkgconf/2.4.3: 27 files, 424.5KB, built in 1 minute 26 seconds
==> Installing python@3.13 dependency: mpdecimal
==> ./configure
==> make
==> make install
🍺  /usr/local/Cellar/mpdecimal/4.0.1: 22 files, 631.1KB, built in 1 minute 4 seconds
==> Installing python@3.13 dependency: ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2025-02-25
Already downloaded: /Users/xxxxxxxxx/Library/Caches/Homebrew/downloads/6c1debb525d4dc6007afae4cd2b772105111632b22fc28506550f6dfe27c6d52--ca-certificates-2025-02-25.bottle_manifest.json
==> Pouring ca-certificates--2025-02-25.all.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /usr/local/Cellar/ca-certificates/2025-02-25: 4 files, 235.9KB
==> Installing python@3.13 dependency: openssl@3
==> perl ./Configure --prefix=/usr/local/Cellar/openssl@3/3.5.0 --openssldir=/usr/local/etc/openssl@3 --libdir=lib no-ssl3 no-ssl3-method no-zlib darwin64-x86_64-cc enable-ec_nistp_64_gcc_128
==> make
==> make install MANDIR=/usr/local/Cellar/openssl@3/3.5.0/share/man MANSUFFIX=ssl
==> make HARNESS_JOBS=4 test TESTS=-test_afalg
==> Downloading https://formulae.brew.sh/api/formula.jws.json
🍺  /usr/local/Cellar/openssl@3/3.5.0: 7,554 files, 36MB, built in 24 minutes 6 seconds
==> Installing python@3.13 dependency: readline
==> Patching
==> Applying readline82-001
==> Applying readline82-002
==> Applying readline82-003
==> Applying readline82-004
==> Applying readline82-005
==> Applying readline82-006
==> Applying readline82-007
==> Applying readline82-008
==> Applying readline82-009
==> Applying readline82-010
==> Applying readline82-011
==> Applying readline82-012
==> Applying readline82-013
==> ./configure --with-curses
==> make install SHLIB_LIBS=-lcurses
🍺  /usr/local/Cellar/readline/8.2.13: 51 files, 1.7MB, built in 1 minute 3 seconds
==> Installing python@3.13 dependency: sqlite
==> ./configure --enable-readline --disable-editline --enable-session --with-readline-cflags=-I/usr/local/opt/readline/include --with-readline-ldflags=-L/usr/local/opt/readline/lib -lreadline
==> make install
🍺  /usr/local/Cellar/sqlite/3.49.2: 13 files, 4.7MB, built in 1 minute 41 seconds
==> Installing python@3.13 dependency: xz
==> ./configure --disable-silent-rules --disable-nls
==> make check
==> make install
🍺  /usr/local/Cellar/xz/5.8.1: 96 files, 2.5MB, built in 1 minute 59 seconds
==> Installing python@3.13 dependency: expat
==> ./configure --mandir=/usr/local/Cellar/expat/2.7.1/share/man
==> make install
🍺  /usr/local/Cellar/expat/2.7.1: 23 files, 660.9KB, built in 53 seconds
==> Installing python@3.13
==> Patching
==> Applying 3.13-sysconfig.diff
==> ./configure --enable-ipv6 --datarootdir=/usr/local/Cellar/python@3.13/3.13.3/share --datadir=/usr/local/Cellar/python@3.13/3.13.3/share --without-ensurepip --enable-loadable-sqlite-extensions --with-o
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python@3.13/3.13.3
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python@3.13/3.13.3/share/python@3.13
==> /usr/local/Cellar/python@3.13/3.13.3/bin/python3.13 -m venv /private/tmp/pythonA3.13-20250512-34034-8vs88d/Python-3.13.3/whl_build
==> /private/tmp/pythonA3.13-20250512-34034-8vs88d/Python-3.13.3/whl_build/bin/pip3 install -v --no-binary :all: --no-index .
==> /private/tmp/pythonA3.13-20250512-34034-8vs88d/Python-3.13.3/whl_build/bin/pip3 install -v --no-binary :all: --no-index .
==> /private/tmp/pythonA3.13-20250512-34034-8vs88d/Python-3.13.3/whl_build/bin/pip3 install -v --no-binary :all: --no-index .
==> /private/tmp/pythonA3.13-20250512-34034-8vs88d/Python-3.13.3/whl_build/bin/pip3 wheel -v --no-binary :all: --no-index --wheel-dir=/usr/local/Cellar/python@3.13/3.13.3/libexec .
==> /private/tmp/pythonA3.13-20250512-34034-8vs88d/Python-3.13.3/whl_build/bin/pip3 wheel -v --no-binary :all: --no-index --wheel-dir=/usr/local/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versi
==> /usr/local/Cellar/python@3.13/3.13.3/bin/python3.13 -Im ensurepip
==> /usr/local/Cellar/python@3.13/3.13.3/bin/python3.13 -Im pip install -v --no-index --upgrade --isolated --target=/usr/local/Cellar/python@3.13/3.13.3/lib/python3.13/site-packages /usr/local/Cellar/pyth
==> Caveats
Python is installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, are installed into
  /usr/local/opt/python@3.13/libexec/bin

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
🍺  /usr/local/Cellar/python@3.13/3.13.3: 9,261 files, 205.6MB, built in 22 minutes 3 seconds
==> Running `brew cleanup python@3.13`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /usr/local/Cellar/python/3.7.5... (4,009 files, 61.4MB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/python@3.13--flit-core--3.12.0.tar.gz... (52.4KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/python@3.13--patch--e1c2699cf3e39731a19207ed69400a67336cda7767aa08f6f46029f26b1d733b.diff... (1.7KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/python@3.13--pip--25.0.1.tar.gz... (1.9MB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/python@3.13--setuptools--78.1.0.tar.gz... (1.3MB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/python@3.13--wheel--0.45.1.tar.gz... (105KB)
Warning: The following dependents of upgraded formulae are outdated but will not
be upgraded because they are not bottled:
  socat
  putty
==> No outdated dependents to upgrade!
==> Checking for dependents of upgraded formulae...
Disable this behaviour by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> No broken dependents to reinstall!
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /usr/local/Cellar/pkg-config/0.28... (10 files, 588.4KB)
Removing: /usr/local/Cellar/readline/6.3.8... (46 files, 2MB)
Removing: /usr/local/Cellar/readline/7.0.3_1... (46 files, 1.5MB)
Removing: /usr/local/Cellar/readline/8.0.1... (48 files, 1.5MB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--1ea434957d6ec3a7b61763f1f3552dad0ebdd6754d65888b5cd6d80db3a788a8... (5.6KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--24f587ba46b46ed2b1868ccaf9947504feba154bb8faabd4adaea63ef7e6acb0... (1.2KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--3d9885e692e1998523fd5c61f558cecd2aafd67a07bd3bfe1d7ad5a31777a116... (2.2KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--5911a5b980d7900aabdbee483f86dab7056851e6400efb002776a0a4a1bab6f6... (1.4KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--622ba387dae5c185afb4b9b20634804e5f6c1c6e5e87ebee7c35a8f065114c99... (1.5KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--6c8adf8ed4a2ca629f7fd11301ed6293a6248c9da0c674f86217df715efccbd3... (2.8KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--758e2ec65a0c214cfe6161f5cde3c5af4377c67d820ea01d13de3ca165f67b4c... (2.6KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--79572eeaeb82afdc6869d7ad4cba9d4f519b1218070e17fa90bbecd49bd525ac... (1.7KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--a177edc9d8c9f82e8c19d0630ab351f3fd1b201d655a1ddb5d51c4cee197b26a... (1.7KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--bbf97f1ec40a929edab5aa81998c1e2ef435436c597754916e6a5868f273aff7... (1.2KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--c7b45ff8c0d24d81482e6e0677e81563d13c74241f7b86c4de00d239bc81f5a1... (3.0KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--e0013d907f3a9e6482cc0934de1bd82ee3c3c4fd07a9646aa9899af237544dd7... (1.8KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/readline--patch--e06503822c62f7bc0d9f387d4c78c09e0ce56e53872011363c74786c7cd4c053... (1.1KB)
Removing: /usr/local/Cellar/sqlite/3.30.1... (11 files, 3.9MB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/trivy--0.24.4.tar.gz... (15.4MB)
Removing: /usr/local/Cellar/xz/5.2.4... (92 files, 1MB)
==> Autoremoving 1 unneeded formula:
gdbm
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/portable-ruby-2.6.8.yosemite.bottle.tar.gz... (8.8MB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/pip_cache... (10 files, 3.1MB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/357177b96309c7b84f9b3782b6e005d3106bdc47/Formula/expat.rb... (2.8KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/357177b96309c7b84f9b3782b6e005d3106bdc47/Formula/lzip.rb... (2.0KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/357177b96309c7b84f9b3782b6e005d3106bdc47/Formula/mpdecimal.rb... (2.4KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/357177b96309c7b84f9b3782b6e005d3106bdc47/Formula/openssl@3.rb... (7.3KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/357177b96309c7b84f9b3782b6e005d3106bdc47/Formula/pkgconf.rb... (3.8KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/357177b96309c7b84f9b3782b6e005d3106bdc47/Formula/readline.rb... (5KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/357177b96309c7b84f9b3782b6e005d3106bdc47/Formula/sqlite.rb... (3.2KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/357177b96309c7b84f9b3782b6e005d3106bdc47/Formula/xz.rb... (2.4KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/expat.rb... (2.8KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/lzip.rb... (2.0KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/mpdecimal.rb... (2.4KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/openssl@3.rb... (7.3KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/pkgconf.rb... (3.8KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/readline.rb... (5KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/sqlite.rb... (3.2KB)
Removing: /Users/xxxxxxxxx/Library/Caches/Homebrew/api-source/Homebrew/homebrew-core/c5976bed6c1703d4233a97d117934eaf0750274b/Formula/xz.rb... (2.4KB)
Removing: /Users/xxxxxxxxx/Library/Logs/Homebrew/trivy... (120B)
Removing: /usr/local/lib/python3.7/site-packages/__pycache__/easy_install.cpython-37.pyc... (283B)
Removing: /usr/local/lib/python3.7/site-packages/__pycache__/sitecustomize.cpython-37.pyc... (1.4KB)
Removing: /usr/local/lib/python3.7/site-packages/__pycache__/six.cpython-37.pyc... (26KB)
Pruned 4 symbolic links and 57 directories from /usr/local
==> Caveats
==> python@3.13
Python is installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, are installed into
  /usr/local/opt/python@3.13/libexec/bin

See: https://docs.brew.sh/Homebrew-and-Python

やっと成功したようです。

内容を確認してみます。

mba:~$ brew info python
==> python@3.13: stable 3.13.3
Interpreted, interactive, object-oriented programming language
https://www.python.org/
Installed
/usr/local/Cellar/python@3.13/3.13.3 (9,261 files, 205.6MB) *
  Built from source on 2025-05-12 at 00:44:04
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/python@3.13.rb
License: Python-2.0
==> Dependencies
Build: pkgconf ✔
Required: mpdecimal ✔, openssl@3 ✔, sqlite ✔, xz ✔, expat ✔
==> Caveats
Python is installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, are installed into
  /usr/local/opt/python@3.13/libexec/bin

See: https://docs.brew.sh/Homebrew-and-Python
==> Analytics
install: 281,199 (30 days), 795,137 (90 days), 1,961,168 (365 days)
install-on-request: 101,394 (30 days), 280,367 (90 days), 555,344 (365 days)
build-error: 607 (30 days)

大丈夫そうですね。

最後にパスを通せば完了です。

mba:~$ vi ~/.bash_profile
--
### for Python
export PATH="/usr/local/bin/python3:$PATH"
export PATH="/usr/local/opt/python@3.13/libexec/bin:$PATH"

最新の設定を読み込ませます。

mba:~$ source ~/.bash_profile

これでPython3が使える状態になりました。

mba:~$ python --version
Python 3.13.3

AWS認定の再認定後の有効期限に関する豆知識

現状のAWS認定資格の有効期限は取得から3年間ですが、数年単位で時間が空くと毎回調べたことを忘れてしまいますので、次回から調べなくても良いよう今回調べた内容を書き留めておきます。

疑問

AWS再認定時の疑問ズバリそれは、再認定時に更新される認定期間についてです。

  1. 再認定の対象となる現認定資格の満了時から3年間
  2. 再認定受験して合格した日から3年間

いつも、どっちだっけ?と調べているような気がします。

結論

正解は【 2. 再認定受験して合格した日から3年間 】です。

根拠

再認定の公式サイトに以下のように記載されています。

AWS による認定は、取得した日から 3 年間有効となります。

確かにAWS認定アカウントの画面で確認してみたらそうなってますね。

例:AWS Certified DevOps Engineer - Professional

2020-11-29:初回取得

↕ 認定期間 #1

2023-11-11:再認定取得

↕ 認定期間 #2

2026-11-11:有効期限

参考

今回の調査で参考にした情報です。

Mercuryで作成したWebアプリを生成AI(Gemini先生)がサクッと修正してくれた件

以前Mercuryで作成した日の出・日の入を計算するWebアプリに

blog.orinbou.info

以下の警告が出力されるようになってしまいました。

<ipython-input-1-511780b4e84b>:98: MatplotlibDeprecationWarning: The plot_date function was deprecated in Matplotlib 3.9 and will be removed in 3.11. Use plot instead. plt.plot_date(x_dates, y_sr_times, markersize=1, color='darkorange') <ipython-input-1-511780b4e84b>:99: MatplotlibDeprecationWarning: The plot_date function was deprecated in Matplotlib 3.9 and will be removed in 3.11. Use plot instead. plt.plot_date(x_dates, y_ss_times, markersize=1, color='darkblue') <ipython-input-1-511780b4e84b>:115: MatplotlibDeprecationWarning: The plot_date function was deprecated in Matplotlib 3.9 and will be removed in 3.11. Use plot instead. plt.plot_date(x_dates, y_daytimes, markersize=1, color='darkorange')

ぜんぜん難しい内容ではありませんが正直めんどくさいなぁと思い試しにGeminiに丸投げしたらサクッと修正してくれました(笑) しかも日本語で優しく丁寧に教えてくれます。

一旦 Jupyter NotebookGoogle Colab)で修正コードを確認して動作確認したうえで、再度 Mercury Cloud にデプロイ(アップロード)して最終確認してみます。

ちゃんと修正されてますね。よしよし👍

https://daytime.runmercury.com/app/sample

まだ修正内容の妥当性や最終的なチェックをする必要はありますが、この程度の修正はもう人間がやる必要ない世界なんですね。素晴らしい👏

よく使用するk8sのリソースのデフォルト値(Service、Deployment、Pod)まとめ

毎回調べるのが面倒なので、よく使用するk8sのリソースのデフォルト値を表にまとめました。

今回の対象リソースは以下3種類で、k8sの基本中の基本のリソースです。

  • Service
  • Deployment
  • Pod

以下の表はすべてオブジェクトの spec 配下の設定のデフォルト値です。

Service

設定項目 デフォルト値
ports protocol TCP
type ClusterIP
sessionAffinity None
externalTrafficPolicy Cluster
internalTrafficPolicy Cluster
sessionAffinityConfig clientIP timeoutSeconds 10800
allocateLoadBalancerNodePorts true

参照:

Deployment

設定項目 デフォルト値
replicas 1
minReadySeconds 0
strategy type RollingUpdate
rollingUpdate maxSurge 25%
maxUnavailable 25%
revisionHistoryLimit 10
progressDeadlineSeconds 600
paused false

参照:

Pod

設定項目 デフォルト値
enableServiceLinks true
tolerations operator Equal
preemptionPolicy PreemptLowerPriority
topologySpreadConstraints maxSkew 1
whenUnsatisfiable DoNotSchedule
restartPolicy Always
terminationGracePeriodSeconds 30
setdostnameAsFQDN false
dnsPolicy ClusterFirst
hostNetwork false
hostPID false
hostIPC false
shareProcessNamespace false
securityContext (empty)
hostUsers true
containers /
initContainers
/
ephemeralContainers
imagePullPolicy Always
ports protocol TCP
volumeMounts mountPropagation None
readOnly false
recursiveReadOnly None
subPatd "" (volume's root)
subPatdExpr "" (volume's root)
resources resizePolicy[] restartPolicy NotRequired
terminationMessagePatd /dev/termination-log
terminationMessagePolicy File
securityContext procMount Default
privileged false
readOnlyRootFilesystem false
stdin false
stdinOnce false
tty false
lifecycle postStart /
preStop
httpGet scheme HTTP
livenessProbe /
readinessProbe /
startupProbe
httpGet scheme HTTP
periodSeconds 10
timeoutSeconds 1
failuretdreshold 3
successtdreshold 1

参照:

k8s Deploymentのラベルの扱いについて

先日CKADを再取得した際、Deploymentのラベルの扱いについて再認識したことがあったので備忘メモを残しておきます。

一般的なDeploymentのラベル

よく見るDeploymentの例では、以下の例のようなラベル(★印)が定義されています。

例:controllers/nginx-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx ←★任意:このリソース(Deployment)のラベル
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx ←★必須:Deploymentが管理するPodのラベル ・・・【A】
  template:
    metadata:
      labels:
        app: nginx ←★必須:このリソース(Deployment)配下のPodのラベル ・・・【B】
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

それぞれのラベルの意味はkubernetes公式ドキュメント Deployment | Kubernetes にも記載されており【任意/必須】も含めて上記のような役割を担っています。

apply時にエラーとなるパターン

必須の【A】と【B】は省略できず、例えば以下のようなパターンではapply時にエラーとなりリソースを生成できません。(A ⊈ B)

パターン① 【A】(未定義):.spec.selector の定義が存在しない
The Deployment "nginx-deployment" is invalid: 
* spec.selector: Required value
* spec.template.metadata.labels: Invalid value: map[string]string{"app":"nginx"}: `selector` does not match template `labels`
パターン② 【A】(未定義):.spec.selector の定義は存在するがラベルが未定義
The Deployment "nginx-deployment" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string(nil), MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: empty selector is invalid for deployment
パターン③ 【A】app: nginx 【B】(未定義):.spec.template.metadata.labels の定義は存在するがラベルが未定義
The Deployment "nginx-deployment" is invalid: spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` does not match template `labels`
パターン④ 【A】app: nginx 【B】app: xxxxx:.spec.template.metadata.labels の定義は存在するがラベルが不一致
The Deployment "nginx-deployment" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"app":"xxxxx"}: `selector` does not match template `labels`

apply時にエラーとならないパターン

ラベルは複数定義できるため、厳密にすべてのラベルが完全に一致している必要があるかと言えばそうではありません。

以下のようなパターンはリソースを生成できます。(A ⊆ B)

パターン⑤ 【A】app: nginx 【B】app: nginx + age: fifty

定義:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
        age: fifty
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

をapplyすると以下のように問題なくリソース作成できます。

kubectl apply -f deploy.yaml 
deployment.apps/nginx-deployment created

kubectl get pods --show-labels 
NAME                                READY   STATUS    RESTARTS   AGE   LABELS
nginx-deployment-7f5b4c8c69-k458q   1/1     Running   0          27s   age=fifty,app=nginx,pod-template-hash=7f5b4c8c69
nginx-deployment-7f5b4c8c69-kb6n2   1/1     Running   0          27s   age=fifty,app=nginx,pod-template-hash=7f5b4c8c69
nginx-deployment-7f5b4c8c69-vkrlh   1/1     Running   0          27s   age=fifty,app=nginx,pod-template-hash=7f5b4c8c69
パターン⑥ 【A】app: nginx 【B】app: xxxxx + app: yyyyy+ app: zzzzz+ app: nginx

※こんなことする人は居ないと思いますが試しにやってみました。(key重複は後勝ちなんですね😅)

定義:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: xxxxx
        app: yyyyy
        app: zzzzz
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

をapplyすると以下のように問題なくリソース作成できます。

kubectl apply -f deploy.yaml
deployment.apps/nginx-deployment created

kubectl get pods --show-labels 
NAME                                READY   STATUS    RESTARTS   AGE   LABELS
nginx-deployment-647677fc66-8lrnr   1/1     Running   0          12s   app=nginx,pod-template-hash=647677fc66
nginx-deployment-647677fc66-gchpd   1/1     Running   0          12s   app=nginx,pod-template-hash=647677fc66
nginx-deployment-647677fc66-shcvh   1/1     Running   0          12s   app=nginx,pod-template-hash=647677fc66

所感

k8sのリソースまわりは公式ドキュメントなどを読んでもイマイチ正しく理解できたかいつもモヤモヤしてしまいます。 今回のように試験勉強でハマったり気になったりしたことは実際に手を動かしてコマンドを叩いて検証するのが一番スッキリしますし、 単に機械的に資格を取得するための学習だけをするのは非常にもったいないので、学びの機会として今後もうまく利用していきたいところです。

参考情報

今回は以下の情報を参考にさせてもらいました。🙇‍♂️

2025-04-25 Certified Kubernetes Application Developer (CKAD) を再取得しました【未だ四冠🥺】🐳🐳🐳🐳

直近またk8sのお仕事をすることになったのと Certified Kubernetes Security Specialist (CKS) の有効期限が切れる前に一度 Kubestronaut の称号(と限定ジャケット)をゲットしておきたかったので 認定Kubernetesアプリケーション開発者 (CKAD-JP) を再取得することにしました。結果としてはCKADを再取得することには成功したのですが、 Kubestronaut の称号を得ることには失敗しました。これまでの受験では発生しなかったトラブルが何度も発生したので、後学&備忘録として経緯を記録しておこうと思います。

 

Kubernetes認定資格

本日(2025年4月27日)時点ではLinux Foundationが認定するKubernetesの認定資格は、次の5種類(KCNA/KCSA/CKA/CKAD/CKS)があります。また、2024年3月から新たに Kubestronautプログラム なるものが開始されており、これら5種類を全冠した人に与えられる新たな称号です。k8sエンジニアのコレクター心理をくすぐるいやらしい戦略ですね(笑)

今回、改めて認定有効期間の最新動向を調べてみましたが昨年アナウンスされた

2024 年認定有効期限ポリシーの変更 - Linux Foundation - トレーニング

2024年4月1日から全ての認定期間が24ヶ月(2年)に変更されている点 から変更はありませんでした。

そして、ご存じの通り認定試験の価格も順調に値上げされており、このようなアナウンスがでておりました。(ま、これはいつものことですね…💸)

2025年2月4日よりCKA、CKAD、CKS、LFCS 認定試験の価格変更のお知らせ - The Linux Foundation

略称 正式名 概要

KCNA

KCNA-JP

  • Kubernetes and Cloud Native Associate(KCNA)
  • 認定Kubernetesクラウドネイティブアソシエイト(KCNA-JP)
Kubernetesと広範なクラウド ネイティブ エコシステムに関する基本的な知識とスキルを証明する(有効認定期間:2年間

KCSA

  • Kubernetes and Cloud Native Security Associate(KCSA)
  • 認定Kubernetesクラウドネイティブセキュリティアソシエイト (KCSA)
Kubernetesクラスタのベースラインセキュリティ設定を理解し、セキュリティ制御の強化/テストと監視/脅威と脆弱性の強化に参加し、コンプライアンス目標を達成できるスキルを証明します(有効認定期間:2年間

CKA

CKA-JP

  • Certified Kubernetes Administrator (CKA)
  • 認定Kubernetes管理者  (CKA-JP)
Kubernetes管理者の責任を遂行するスキル、知識、および能力を備えていることを保証する(有効認定期間:2年間

CKAD

CKAD-JP

  • Certified Kubernetes Application Developer (CKAD)
  • 認定Kubernetesアプリケーション開発者 (CKAD-JP)
ユーザーが Kubernetes 用のクラウドネイティブ アプリケーションを設計、構築、デプロイできることを証明する(有効認定期間:2年間

CKS

CKS-JP

  • Certified Kubernetes Security Specialist (CKS)
  • 認定Kubernetesセキュリティスペシャリスト (CKS-JP)
Kubernetesの熟練した実践者(CKA認定が必要)であり、コンテナベースのアプリケーションやKubernetesプラットフォームの構築、デプロイ、ランタイム時のセキュリティを確保するための幅広いベストプラクティス能力を実証する(有効認定期間:2年間

 

試験対策

今回の試験対策で実践した内容は主に次の2つです。 

1.Udemy

2019年に購入した教材を再利用したので今回新たに教材を購入しませんでした。なんと嬉しいことに最新動向に追従して教材がちゃんとアップデートされていました。これはありがたいですね。

Kubernetes Certified Application Developer (CKAD) Training | Udemy

主に以下の模擬試験的な教材を中心に実際に手を動かして繰り返し復習しました。

  • セクション12: Mock Exams
  • セクション11: Lightning Labs

セクション12→11の順に実施する理由は、セクション11の方が難易度が高いためです。こちらの過去記事にも記載していますので併せてご覧ください。

2.Killer Shell - Exam Simulators

試験を申し込むと教材として利用できるようになります。

Killer Shell - Exam Simulators

主に以下の模擬試験的な教材を中心に実際に手を動かして繰り返し復習しました。

* CKAD Simulator Kubernetes 1.32

こちらの教材には有効期限があるので模擬試験として利用する場合はタイミングを考慮して利用しましょう。ただ、模擬試験として利用する有効期限が過ぎても解答と解説は閲覧することができます。目的に応じてうまく活用しましょう。

 

受験時のトラブルの経緯

今回の受験で実際に起きたことを時系列に沿って記載すると以下のような感じです。

# 日時 事象

1

2025年04月06日(日)

10:00~10:30

★ 受験(1回目):無効

試験開始後30分で PSI Secure Browser がフリーズして試験が強制終了する

2

2025年04月06日(日)

10:36

終了後すぐに

http://trainingsupport.linuxfoundation.org/

でサポートへチケットを起票する

3

2025年04月08日(火)

20:32

採点中(Grading in progress)のまま48時間以上経過してもサポートから回答がないので起票したチケットにコメントを追記する

4

2025年04月09日(水)

12:10

採点中(Grading in progress)のまま72時間以上経過してもサポートから回答がないので起票したチケットにコメントを追記する
5

2025年04月09日(水)

17:52

サポートから再度受験が可能となった旨の連絡がくる
6

2025年04月11日(金)

04:00~04:30

★ 受験(2回目):無効

事前にPCスペックやネットワーク帯域などを入念にチェックして試験に臨むも再び試験開始後30分で PSI Secure Browser がフリーズして試験が強制終了する

7

2025年04月11日(金)

10:20

終了後しばらく様子を見つつ

http://trainingsupport.linuxfoundation.org/

でサポートへチケットを起票する

8

2025年04月16日(水)

23:13

採点中(Grading in progress)のまま1週間近く経過してもサポートから回答がないので起票したチケットにコメントを追記する
9

2025年04月17日(木)

00:00

CKSの資格を失効する(このタイミングで Kubestronaut になる資格を喪失する)

10

2025年04月17日(木)

18:44

あまりにもサポートから回答がないので心配になって起票したチケットに更に催促のコメントを追記する
11

2025年04月17日(木)

19:47

サポートから再度受験が可能となった旨の連絡がくる
12

2025年04月20日(日)

16:00~18:00

★ 受験(3回目):不合格

受験時に使用するPCを再セットアップ(OS再インストール)して受験したところ PSI Secure Browser がフリーズすることなく受験が完了する(試験結果は不合格だったが、最後まで受験できたことに安心する)

13

2025年04月25日(金)

04:30~06:30

☆ 受験(4回目):合格

PSI Secure Browser がフリーズすることなく受験が完了する

今回のトラブルに対処するためネットに有益な情報がないか検索(例:PSI Secure Browser、フリーズ、など)してみたところ、数は多くはないものの、似たような事象で困っている人は一定数いそうでした。

いずれも、これといった有効な解決策はないようで、とにかく気長にサポートとキャッチボールをしながら、受験する環境を変えて原因の切り分けをするというアプローチしか無さそうです。(こうなると試験センターで受験するという選択肢も欲しいですね)

 

受験時のトラブルの教訓

1.計画について

今回は初回受験から受験終了まで20日(3週間弱)を要しました。目論見としては、CKSの資格を失効する2025年4月17日(木)までに、ギリギリ2回(初回受験+リテイク)受験して合格するというスケジュールで臨んだのですが完全に計画が破綻してしまいました。これまでの受験では今回のようなトラブルには遭遇したことがなかったので、まさかここまで時間がかかるとは想像もしていませんでしたが、今後は今回のようなトラブルが発生することも念頭に置きながら計画を立てて臨む必要があると痛感しました。加えて、サポートとのキャッチボールのリードタイムも想像より長い印象でした。特に2回目フリーズ時は催促して1週間くらいだったので、もし強めの催促をしなかったらもっと放置された可能性も高かったように思います。

2.環境について

なるべく今回のようなトラブルに遭遇したくなかったので、過去に受験で使用した実績のあるPCを利用して受験に臨んだのですが、残念なトラブルに見舞われてしまいました。最終的にPCを再セットアップ(OS再インストール)して受験することで試験を完了させることができたので、少なくともネットワーク帯域やH/Wの問題ではなく、OSにインストールされている何らかのソフトウェアが影響していた可能性が高いことまでは分りましたが詳細は不明です。試験センターで受験できないスタイルの資格試験なので、難しいとは思いますが受験前のシステムチェックなどでもう少し厳密にチェックして事前に教えてほしいところです。

 

試験時の注意点

今回は基本的には問題文を日本語の表示で受験しましたが、途中明らかにおかしな問題文があり、英語の表示に切り替えたところ、問題文の原文(英語)の多くが無視され欠落した意味の分からない問題がありました。問題文のタグ名が

undefined: undefined

と明らかに不自然な表示になっていたので気付けましたが、自動翻訳の怖いところです。多言語対応しているとはいえ、翻訳後の問題文のチェックはあまりされていない前提で試験に臨むのが良さそうです。

 

さいごに

結局今回は Kubestronaut になることはできませんでした。CKSを再取得するモチベーションが湧けば改めて挑戦したいと思いますが、なかなか手間もお金もかかることなのでもう少し考えてから決めたいと思います。それでは一旦お疲れさまでした🙇‍♂️