> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ale.run/llms.txt
> Use this file to discover all available pages before exploring further.

# GKEクラスタ設定

> gcloud CLIを活用したGKEクラスタ作成ガイドです。

***

## GKEクラスタの作成

> 以下の内容を参考にして、GKEクラスターを作成するためのgcloudコマンドを実行します。

```yaml theme={null}
gcloud beta container --project $GCP_PROJECT_ID clusters create $CLUSTER_NAME \
  --region $GCP_REGION \
  --tier "standard" \
  --cluster-version "1.30.5-gke.1443001" \
  --machine-type "e2-standard-4" \
  --image-type "COS_CONTAINERD" \
  --disk-size "100" \
  --enable-ip-alias \
  --enable-google-cloud-access \
  --addons HorizontalPodAutoscaling,HttpLoadBalancing,GcePersistentDiskCsiDriver \
  --enable-autoupgrade \
  --enable-autorepair \
  --enable-network-policy \
  --node-locations $NODE_LOCATIONS
```

## Nginx Ingress Controller

> Nginx Ingress Controllerをインストールします。

```bash theme={null}
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
```

```bash theme={null}
helm install ingress-nginx ingress-nginx/ingress-nginx \
  --version 4.11.2 \
  --namespace ingress-nginx --create-namespace \
  --set controller.service.type=LoadBalancer \
  --set controller.allowSnippetAnnotations=true \
  --set controller.admissionWebhooks.enabled=false
```

## Cert Manager

> Helmを使用してCert Managerをインストールします。

```bash theme={null}
helm repo add jetstack https://charts.jetstack.io
helm repo update
```

```bash theme={null}
helm install \
      cert-manager jetstack/cert-manager \
      --namespace cert-manager \
      --create-namespace \
      --version v1.15.3 \
      --set crds.enabled=true
```

## GKE standardストレージクラスの設定

> PVC作成テストのために以下のコマンドを実行してください。

```bash theme={null}
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-test
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: standard
  resources:
    requests:
      storage: 1Gi
EOF
```

<Note>
  作成したPVCの状態を確認します。正常に作成されると、STATUSはBoundになります。

  ```bash theme={null}
  kubectl get pvc pvc-test
  ```

  ```bash theme={null}
  NAME       STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS              VOLUMEATTRIBUTESCLASS   AGE
  pvc-test   Bound    pvc-40b4e7fa-54e7-4d2b-be45-6b4e7e191b00   1Gi        RWO            standard                  <unset>                 16s
  ```
</Note>
