外部クライアントのためにICAPサービスをEKSクラスターの外部に公開する必要がある場合、AWS NLBを使用できます。
ICAP (インターネットコンテンツ適応プロトコル) サーバは次の理由でネットワークロードバランサが必要です:
- ICAPはポート1344で動作し、独自のレイヤー7プロトコルを使用します
- ALBはHTTPベースのプロトコルのみをサポートしています
- NLBはレイヤー4 (TCP) で動作し、ICAPトラフィックを適切に処理できます
前提条件:
- EKSクラスターが稼働中
kubectl
とhelm
が適切なアクセスで構成されています- AWS CLIがインストールされ、設定されました
- ロードバランサーリソースを作成するためのIAM権限
手順
- AWSロードバランサーコントローラーをインストールします (まだインストールされていない場合):
# Create IAM policy curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/install/iam_policy.json aws iam create-policy \ --policy-name AWSLoadBalancerControllerIAMPolicy \ --policy-document file://iam-policy.json # Create IAM role and service account eksctl create iamserviceaccount \ --cluster <your-cluster-name> \ --namespace kube-system \ --name aws-load-balancer-controller \ --attach-policy-arn arn:aws:iam::<your-account-id>:policy/AWSLoadBalancerControllerIAMPolicy \ --approve # Install controller helm repo add eks https://aws.github.io/eks-charts helm repo update helm install aws-load-balancer-controller eks/aws-load-balancer-controller \ -n kube-system \ --set clusterName=<your-cluster-name> \ --set serviceAccount.create=false \ --set serviceAccount.name=aws-load-balancer-controller
- NLBのサブネットにタグを付ける:
- に移動します。
- NLBが使用する各サブネットにこれらのタグを追加してください。
kubernetes.io/cluster/<your-cluster-name> = shared kubernetes.io/role/elb = 1 (for public) or kubernetes.io/role/internal-elb = 1 (for private)
注意
サブネットに十分な利用可能なIPがあることを確認してください。
- 外部アクセス用のvalues.yamlを更新
scanner: # Other scanner settings remain unchanged # Enable external NLB service for ICAP externalService: enabled: true annotations: service.beta.kubernetes.io/aws-load-balancer-type: "external" service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "ip" service.beta.kubernetes.io/aws-load-balancer-scheme: "internet-facing" icapPort: 1344
- NLB構成でデプロイメントを更新する:
helm upgrade my-release visionone-filesecurity/visionone-filesecurity \ -n visionone-filesecurity \ -f my-values.yaml
- NLBデプロイメントを確認する:
# Check the service status kubectl get service -n visionone-filesecurity | grep scanner-lb # Get the NLB DNS name NLB_DNS=$(kubectl get service -n visionone-filesecurity my-release-visionone-filesecurity-scanner-lb -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') echo "Your NLB DNS name is: $NLB_DNS"
- DNS (Route53) を構成する
- に移動します。
- Aレコードを作成します。
- 名前: icap.example.com
- タイプ: A (エイリアス)
- トラフィックをルートする先: ネットワークロードバランサー
- NLBを選択してください
- c-icap-clientをインストールして接続をテストしてください。
# Install c-icap-client sudo apt-get install c-icap # Test with file scanning c-icap-client -i icap.example.com -s scan -p 1344 -f sample.txt -x "X-scan-file-name: sample.txt"
- ICAPサービスでTLSを有効にしたい場合は、my-values.yamlでNLBの設定を更新してください。
scanner: externalService: enabled: true type: LoadBalancer annotations: service.beta.kubernetes.io/aws-load-balancer-type: "external" service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "ip" service.beta.kubernetes.io/aws-load-balancer-scheme: "internet-facing" # TLS configuration service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:region:account-id:certificate/certificate-id" icapPort: 1344 Apply this configuration: helm upgrade my-release visionone-filesecurity/visionone-filesecurity \ -n visionone-filesecurity \ -f my-values.yaml