セットアップクラスタと展開OWASPジュースショップ
11223 ワード
EKSクラスタを設定してインストールしましょう
それにKubernetesマニフェストを使用しているOWASP Juice Shop.
マニフェスト
ここではマニフェストファイルは、私たちのdeployment
service .
クベットル
Kubecnetesクラスタと対話するためにKubectlをローカルマシンにインストールしましょう.
All CLI
AWS EKSでクラスタを起動する予定です.そのためには、
aws cliとEksctl.
AWS CLIから始めてください.
IAM
私たちはAWSコマンドを発行するためのアクセスキーを必要とします
URLそれは、ようです
次のページでグループが作成できない場合はグループを作成します.
管理者の管理ポリシーのグループを作成します.
ユーザーは、現在管理者グループにマップすることができます.
私はタグ・ステージをスキップして、最終的にユーザーをつくります.
一旦ユーザが作成されると、最終的なページからアクセスキーIDと秘密のアクセスキーをretreiveすることができます.
私たちは今ホームディレクトリにCDをすることができますし、作成します.ディレクトリ.
京大理
それで、我々はAWS CLIのために重要なセッティングをしました.現在、eksctlインストールを続けましょう.
よりクラスタのカスタマイズについては、EKS getting started guideを参照してください.
クベドフィグ
aws eks cliを使ってクラスタのリストをチェックしましょう.領域を指定するか、リストの前にデフォルト領域を設定する必要があります.私のケースではUS - WAR - 2です.
配備する
ジュースショップのためにKubernetes展開とサービスをつくる時間です.
クリーンアップ
CtrlキーCを押してポートフォワーディングを停止し、ブラウザでアプリケーションを停止します.
削除コマンドを使用してKubernetesオブジェクトを削除できます
それにKubernetesマニフェストを使用しているOWASP Juice Shop.
マニフェスト
ここではマニフェストファイルは、私たちのdeployment
service .
┌─[nc@parrot]─[/tmp]
└──╼ $cat juice-shop.yaml
kind: Deployment
apiVersion: apps/v1
metadata:
name: juice-shop
spec:
template:
metadata:
labels:
app: juice-shop
spec:
containers:
- name: juice-shop
image: bkimminich/juice-shop
selector:
matchLabels:
app: juice-shop
--------
kind: Service
apiVersion: v1
metadata:
name: juice-shop
spec:
type: NodePort
selector:
app: juice-shop
ports:
- name: http
port: 8000
targetPort: 3000
クベットル
Kubecnetesクラスタと対話するためにKubectlをローカルマシンにインストールしましょう.
┌─[nc@parrot]─[/tmp]
└──╼ $curl -sO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
ダウンロードしたkubectlのチェックサムを確認します.┌─[nc@parrot]─[/tmp]
└──╼ $curl -sO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
┌─[nc@parrot]─[/tmp]
└──╼ $echo "$(<kubectl.sha256) kubectl" | sha256sum --check
kubectl: OK
チェックサムが正しいということはOKを言います.インストールの残りをしましょう.─[✗]─[nc@parrot]─[/tmp]
└──╼ $sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
[sudo] password for nc:
┌─[nc@parrot]─[/tmp]
└──╼ $which kubectl
/usr/local/bin/kubectl
┌─[nc@parrot]─[/tmp]
└──╼ $kubectl version --client
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"clean", BuildDate:"2021-09-15T21:38:50Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}
Kubectlをインストールしました.TMPディレクトリからKubectlとチェックサムファイルを削除することができます.┌─[nc@parrot]─[/tmp]
└──╼ $rm kubectl*
All CLI
AWS EKSでクラスタを起動する予定です.そのためには、
aws cliとEksctl.
AWS CLIから始めてください.
─[nc@parrot]─[/tmp]
└──╼ $curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
┌─[nc@parrot]─[/tmp]
└──╼ $unzip awscliv2.zip
┌─[✗]─[nc@parrot]─[/tmp]
└──╼ $sudo ./aws/install
You can now run: /usr/local/bin/aws --version
┌─[nc@parrot]─[/tmp]
└──╼ $aws --version
aws-cli/2.2.46 Python/3.8.8 Linux/5.10.0-6parrot1-amd64 exe/x86_64.parrot.4 prompt/off
AWS CLIがインストールされているので、ダウンロードしたファイルを削除できます.┌─[✗]─[nc@parrot]─[/tmp]
└──╼ $rm -rf aws*
IAM
私たちはAWSコマンドを発行するためのアクセスキーを必要とします
URLそれは、ようです
次のページでグループが作成できない場合はグループを作成します.
管理者の管理ポリシーのグループを作成します.
ユーザーは、現在管理者グループにマップすることができます.
私はタグ・ステージをスキップして、最終的にユーザーをつくります.
一旦ユーザが作成されると、最終的なページからアクセスキーIDと秘密のアクセスキーをretreiveすることができます.
私たちは今ホームディレクトリにCDをすることができますし、作成します.ディレクトリ.
┌─[nc@parrot]─[/tmp]
└──╼ $cd ~
┌─[nc@parrot]─[~]
└──╼ $mkdir .aws
私たちはちょうど資格情報ファイルを作成する必要があります.AWSディレクトリ、以前に取得したアクセスキーIDと秘密アクセスキーを格納します.以下のように、以下のファイルはダミー値を持つことに注意してください.参照のためにこのlinkをチェックしてください.┌─[nc@parrot]─[~]
└──╼ $cat .aws/credentials
[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
京大理
それで、我々はAWS CLIのために重要なセッティングをしました.現在、eksctlインストールを続けましょう.
┌─[nc@parrot]─[~]
└──╼ $curl -s "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
┌─[nc@parrot]─[~]
└──╼ $sudo mv /tmp/eksctl /usr/local/bin/eksctl
[sudo] password for nc:
┌─[nc@parrot]─[~]
└──╼ $eksctl version
0.70.0
十分にやった😅, Eksクラスタを起動しましょう$ eksctl create cluster \
--name my-cluster \
--region us-west-2 \
--fargate
ここで休憩を取る☕, 私は、このステップが少し長くするのを見ました.よりクラスタのカスタマイズについては、EKS getting started guideを参照してください.
クベドフィグ
aws eks cliを使ってクラスタのリストをチェックしましょう.領域を指定するか、リストの前にデフォルト領域を設定する必要があります.私のケースではUS - WAR - 2です.
┌─[✗]─[nc@parrot]─[~]
└──╼ $aws eks list-clusters --region us-west-2
{
"clusters": [
"my-cluster"
]
}
上記のように1クラスタしか存在しない.Kubeconfigを更新し、KubectlをAKSクラスタと対話させることができます.┌─[nc@parrot]─[~]
└──╼ $aws eks update-kubeconfig --name my-cluster --region us-west-2
Added new context arn:aws:eks:us-west-2:<account-id>:cluster/my-cluster to /home/nc/.kube/config
Kubectlを使い始めることができます.─[nc@parrot]─[~]
└──╼ $kubectl config current-context
arn:aws:eks:us-west-2:<account-id>:cluster/my-cluster
クラスタノードは準備ができているはずです.┌─[nc@parrot]─[~]
└──╼ $kubectl get nodes
NAME STATUS ROLES AGE VERSION
fargate-ip-192-168-126-75.us-west-2.compute.internal Ready <none> 6m19s v1.20.7-eks-135321
fargate-ip-192-168-177-91.us-west-2.compute.internal Ready <none> 6m16s v1.20.7-eks-135321
配備する
ジュースショップのためにKubernetes展開とサービスをつくる時間です.
$ kubectl create -f /tmp/juice-shop.yaml
deployment.apps/juice-shop created
service/juice-shop created
いくつかの時点でポッドがあります.┌─[nc@parrot]─[~]
└──╼ $kubectl get po
NAME READY STATUS RESTARTS AGE
juice-shop-699c69578f-qmd8m 1/1 Running 0 34m
イベントをチェックしましょう.┌─[✗]─[nc@parrot]─[~]
└──╼ $kubectl describe po juice-shop-699c69578f-qmd8m | grep -A 15 Events:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning LoggingDisabled 37m fargate-scheduler Disabled logging because aws-logging configmap was not found. configmap "aws-logging" not found
Normal Scheduled 36m fargate-scheduler Successfully assigned default/juice-shop-699c69578f-qmd8m to fargate-ip-192-168-109-122.us-west-2.compute.internal
Normal Pulling 36m kubelet Pulling image "bkimminich/juice-shop"
Normal Pulled 35m kubelet Successfully pulled image "bkimminich/juice-shop" in 33.837789722s
Normal Created 35m kubelet Created container juice-shop
Normal Started 35m kubelet Started container juice-shop
すべてはこれまで良いようです、終点がOKであるならば、見ましょう.┌─[✗]─[nc@parrot]─[~]
└──╼ $kubectl get ep juice-shop
NAME ENDPOINTS AGE
juice-shop 192.168.109.122:3000 38m
そして、このIPは我々のジュース店ポッドのはずです.┌─[nc@parrot]─[~]
└──╼ $kubectl get po -o wide | grep 192.168.109.122
juice-shop-699c69578f-qmd8m 1/1 Running 0 39m 192.168.109.122 fargate-ip-192-168-109-122.us-west-2.compute.internal <none> <none>
マニフェストごとに、サービスはポート8000で機能しなければなりません.検証しましょう.┌─[nc@parrot]─[~]
└──╼ $kubectl get svc juice-shop
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
juice-shop NodePort 10.100.201.210 <none> 8000:32741/TCP 41m
Kubectlのポート転送機能を使用して、localhostにサービスを公開できます.┌─[nc@parrot]─[~]
└──╼ $kubectl port-forward svc/juice-shop 8080:8000
Forwarding from 127.0.0.1:8080 -> 3000
Forwarding from [::1]:8080 -> 3000
アプリケーションは現在ポート8080でアクセスできます.クリーンアップ
CtrlキーCを押してポートフォワーディングを停止し、ブラウザでアプリケーションを停止します.
削除コマンドを使用してKubernetesオブジェクトを削除できます
$ kubectl delete -f /tmp/juice-shop.yaml
最後にクラスタを削除したい場合は、次のようにしてください.┌─[nc@parrot]─[~]
└──╼ $eksctl delete cluster --name my-cluster --region us-west-2
--郵便の終わり--Reference
この問題について(セットアップクラスタと展開OWASPジュースショップ), 我々は、より多くの情報をここで見つけました https://dev.to/aws-builders/aws-eks-setup-cluster-and-deploy-owasp-juice-shop-214jテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol