gavannitsales@ubuntu22:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
923557c064da gcr.io/fourth-elixir-383118/hello-world-container:v1.0 "/usr/bin/gunicorn -…" 2 weeks ago Exited (0) 2 weeks ago nervous_gagarin
b202ef51299f hello-world-container "/usr/bin/gunicorn -…" 2 weeks ago Exited (0) 2 weeks ago gracious_swirles
残ってるコンテナを潰す。
gavannitsales@ubuntu22:~$ docker rm 923557c064da
923557c064da
gavannitsales@ubuntu22:~$ docker rm b202ef51299f
b202ef51299f
gavannitsales@ubuntu22:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
gavannitsales@ubuntu22:~$
dockerイメージも潰す。
gavannitsales@ubuntu22:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world-container latest 5de507c26f8a 2 weeks ago 245MB
gcr.io/fourth-elixir-383118/hello-world-container v1.0 5de507c26f8a 2 weeks ago 245MB
gavannitsales@ubuntu22:~$ docker rmi hello-world-container:latest
Untagged: hello-world-container:latest
gavannitsales@ubuntu22:~$ docker rmi gcr.io/fourth-elixir-383118/hello-world-container:v1.0
Untagged: gcr.io/fourth-elixir-383118/hello-world-container:v1.0
Untagged: gcr.io/fourth-elixir-383118/hello-world-container@sha256:fe215a34dc5b5ea4cc1f22c809798e507562daaf9085e1a8304d91d515758554
Deleted: sha256:5de507c26f8a19e551cf039c5805c670d0efc75a9ce373d8b64eca6502bc79fd
gavannitsales@ubuntu22:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gavannitsales@ubuntu22:~$
ローカルPCへGCRからpull
前にGCRへ登録したイメージをローカルPCへpullする。
gavannitsales@ubuntu22:~$ docker pull gcr.io/fourth-elixir-383118/hello-world-container:v1.0
v1.0: Pulling from fourth-elixir-383118/hello-world-container
2e6e20c8e2e6: Already exists
0551a797c01d: Already exists
512123a864da: Already exists
1e583242b4c3: Already exists
86c34855c25e: Already exists
3b856a94d9d0: Already exists
4f4fb700ef54: Already exists
Digest: sha256:fe215a34dc5b5ea4cc1f22c809798e507562daaf9085e1a8304d91d515758554
Status: Downloaded newer image for gcr.io/fourth-elixir-383118/hello-world-container:v1.0
gcr.io/fourth-elixir-383118/hello-world-container:v1.0
gavannitsales@ubuntu22:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gcr.io/fourth-elixir-383118/hello-world-container v1.0 5de507c26f8a 2 weeks ago 245MB
gavannitsales@ubuntu22:~$
gavannitsales@ubuntu22:~$ docker tag gcr.io/fourth-elixir-383118/hello-world-container:v1.0 hello-world-container
gavannitsales@ubuntu22:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world-container latest 5de507c26f8a 2 weeks ago 245MB
gcr.io/fourth-elixir-383118/hello-world-container v1.0 5de507c26f8a 2 weeks ago 245MB
gavannitsales@ubuntu22:~$
GARへ登録
手続き踏まないと登録はできん。
gcp認証
前と同じようなことする。
gavannitsales@ubuntu22:~$ gcloud auth login
:(中略)
Enter authorization code: xxxxxxxxxxxxxxxxxxx
You are now logged in as [gavannitsales@gmail.com].
Your current project is [fourth-elixir-383118]. You can change this setting by running:
$ gcloud config set project PROJECT_ID
gavannitsales@ubuntu22:~$
gavannitsales@ubuntu22:~$ cat makeGke.sh
gcloud container clusters create narigke --num-nodes=3
gavannitsales@ubuntu22:~$ sh ./makeGke.sh
Default change: VPC-native is the default mode during cluster creation for versions greater than 1.21.0-gke.1500. To create advanced routes based clusters, please pass the `--no-enable-ip-alias` flag
Default change: During creation of nodepools or autoscaling configuration changes for cluster versions greater than 1.24.1-gke.800 a default location policy is applied. For Spot and PVM it defaults to ANY, and for all other VM kinds a BALANCED policy is used. To change the default values use the `--location-policy` flag.
Note: Your Pod address range (`--cluster-ipv4-cidr`) can accommodate at most 1008 node(s).
Creating cluster narigke in us-central1-a... Cluster is being health-checked (master is healthy)...done.
Created
.
To inspect the contents of your cluster, go to: https://console.cloud.google.com/kubernetes/workload_/gcloud/us-central1-a/narigke?project=fourth-elixir-383118
kubeconfig entry generated for narigke.
NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS
narigke us-central1-a 1.25.8-gke.500 34.28.16.121 e2-medium 1.25.8-gke.500 3 RUNNING
gavannitsales@ubuntu22:~$
クラスタの認証情報を取得して接続する。
gavannitsales@ubuntu22:~$ gcloud container clusters get-credentials narigke
Fetching cluster endpoint and auth data.
kubeconfig entry generated for narigke.
gavannitsales@ubuntu22:~$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* gke_fourth-elixir-383118_us-central1-a_narigke gke_fourth-elixir-383118_us-central1-a_narigke gke_fourth-elixir-383118_us-central1-a_narigke
gavannitsales@ubuntu22:~$
Pod起動
GCRのときはこうしてた。
kubectl run hello-world --image=gcr.io/fourth-elixir-383118/hello-world-container:v1.0 --port=8000
GARなのでこうする。 長いなぁ。
kubectl run hello-world --image=us-central1-docker.pkg.dev/fourth-elixir-383118/gavannitsales/hello-world-container:v1.0 --port=8000