コンテンツにスキップ
Kong Logo | Kong Docs Logo
  • ドキュメント
    • API仕様を確認する
      View all API Specs すべてのAPI仕様を表示 View all API Specs arrow image
    • ドキュメンテーション
      API Specs
      Kong Gateway
      軽量、高速、柔軟なクラウドネイティブAPIゲートウェイ
      Kong Konnect
      SaaSのエンドツーエンド接続のための単一プラットフォーム
      Kong AI Gateway
      GenAI インフラストラクチャ向けマルチ LLM AI Gateway
      Kong Mesh
      Kuma と Envoy をベースにしたエンタープライズサービスメッシュ
      decK
      Kongの構成を宣言型で管理する上で役立ちます
      Kong Ingress Controller
      Kubernetesクラスタ内で動作し、Kongをプロキシトラフィックに設定する
      Kong Gateway Operator
      YAMLマニフェストを使用してKubernetes上のKongデプロイメントを管理する
      Insomnia
      コラボレーティブAPI開発プラットフォーム
  • Plugin Hub
    • Plugin Hubを探索する
      View all plugins すべてのプラグインを表示 View all plugins arrow image
    • 機能性 すべて表示 View all arrow image
      すべてのプラグインを表示
      AI's icon
      AI
      マルチ LLM AI Gatewayプラグインを使用してAIトラフィックを管理、保護、制御する
      認証's icon
      認証
      認証レイヤーでサービスを保護する
      セキュリティ's icon
      セキュリティ
      追加のセキュリティレイヤーでサービスを保護する
      トラフィック制御's icon
      トラフィック制御
      インバウンドおよびアウトバウンドAPIトラフィックの管理、スロットル、制限
      サーバーレス's icon
      サーバーレス
      他のプラグインと組み合わせてサーバーレス関数を呼び出します
      分析と監視's icon
      分析と監視
      APIとマイクロサービストラフィックを視覚化、検査、監視
      変革's icon
      変革
      Kongでリクエストとレスポンスをその場で変換
      ログ記録's icon
      ログ記録
      インフラストラクチャに最適なトランスポートを使用して、リクエストと応答データをログに記録します
  • サポート
  • コミュニティ
  • Kongアカデミー
デモを見る 無料トライアルを開始
Kong Ingress Controller
2.12.x LTS
  • Home icon
  • Kong Ingress Controller
  • Deployment
  • Enable the Validating Admission Webhook
report-issue問題を報告する
  • Kong Gateway
  • Kong Konnect
  • Kong Mesh
  • Kong AI Gateway
  • Plugin Hub
  • decK
  • Kong Ingress Controller
  • Kong Gateway Operator
  • Insomnia
  • Kuma

  • ドキュメント投稿ガイドライン
  • 3.4.x (latest) (LTS)
  • 3.3.x
  • 3.2.x
  • 3.1.x
  • 3.0.x
  • 2.12.x (LTS)
  • 2.11.x
  • 2.10.x
  • 2.9.x
  • 2.8.x
  • 2.7.x
  • 2.6.x
  • 2.5.x (LTS)
  • Introduction
    • FAQ
    • Version Support Policy
    • Stages of Software Availability
    • Changelog
  • Concepts
    • Architecture
    • Custom Resources
    • Deployment Methods
    • Kong for Kubernetes with Kong Gateway Enterprise
    • High-Availability and Scaling
    • Resource Classes
    • Security
    • Ingress Resource API Versions
    • Gateway API
    • Expression Based Router
  • Deployment
    • Kong Ingress on Minikube
    • Kong for Kubernetes
    • Kong Enterprise for Kubernetes (DB-less)
    • Kong Enterprise for Kubernetes (DB-backed)
    • Kong Ingress on AKS
    • Kong Ingress on EKS
    • Kong Ingress on GKE
    • Admission Webhook
    • Installing Gateway APIs
  • Guides
    • Getting Started with KIC
    • Upgrading from previous versions
    • Upgrading to Kong 3.x
    • Using Kong Gateway Enterprise
    • Getting Started using Istio
    • Using Custom Resources
      • Using the KongPlugin Resource
      • Using the KongIngress Resource
      • Using KongConsumer and KongCredential Resources
      • Using the TCPIngress Resource
      • Using the UDPIngress Resource
    • Using the ACL and JWT Plugins
    • Using cert-manager with Kong
    • Allowing Multiple Authentication Methods
    • Configuring a Fallback Service
    • Using an External Service
    • Configuring HTTPS Redirects for Services
    • Using Redis for Rate Limiting
    • Integrate KIC with Prometheus/Grafana
    • Configuring Circuit-Breaker and Health-Checking
    • Setting up a Custom Plugin
    • Setting up Upstream mTLS
    • Exposing a TCP/UDP/gRPC Service
      • Exposing a TCP Service
      • Exposing a UDP Service
      • Exposing a gRPC service
    • Using the mTLS Auth Plugin
    • Using the OpenID Connect Plugin
    • Rewriting Hosts and Paths
    • Preserving Client IP Address
    • Using Kong with Knative
    • Using Multiple Backend Services
    • Using Gateway Discovery
    • Routing by Header
  • References
    • KIC Annotations
    • CLI Arguments
    • Custom Resource Definitions
    • Plugin Compatibility
    • Version Compatibility
    • Supported Kong Router Flavors
    • Troubleshooting
    • Kubernetes Events
    • Prometheus Metrics
    • Feature Gates
    • Supported Gateway API Features
enterprise-switcher-icon 次に切り替える: OSS
On this pageOn this page
  • Enable the webhook
  • Test the configuration
    • Verify duplicate KongConsumers
    • Verify incorrect KongPlugins
    • Verify incorrect credential secrets
    • Verify incorrect routes

このページは、まだ日本語ではご利用いただけません。翻訳中です。

旧バージョンのドキュメントを参照しています。 最新のドキュメントはこちらをご参照ください。

Enable the Validating Admission Webhook

The Kong Ingress Controller ships with an admission webhook for KongPlugin and KongConsumer resources in the configuration.konghq.com API group. You can generate TLS certificate and key pair that you need for admission webhook.

Enable the webhook

You can enable webhook using Helm chart, with a script, or manually.

Helm chart
Script
Manual

If you are using the Helm chart, you can enable the webhook by setting ingressController.admissionWebhook.enabled=true in your values.yaml. It is set to true by default as of chart version 2.16.

The chart generates a self-signed certificate by default. The ingressController.admissionWebhook.certificate is set to use a user-provided certificate instead.

If you are using the stock YAML manifests to install and setup Kong for Kubernetes, then you can set up the admission webhook using a script. You need kubectl and openssl installed on your workstation for the script to work.

curl -sL https://raw.githubusercontent.com/Kong/kubernetes-ingress-controller/main/hack/deploy-admission-controller.sh | bash

The results should look like this:

Generating a 2048 bit RSA private key
.......+++
.......................................................................+++
writing new private key to '/var/folders/h2/chkzcfsn4sl3nn99tk5551tc0000gp/T/tmp.SX3eOgD0/tls.key'
-----
secret/kong-validation-webhook created
deployment.apps/ingress-kong patched
validatingwebhookconfiguration.admissionregistration.k8s.io/kong-validations created

Kubernetes API-server makes an HTTPS call to the admission webhook to verify if the custom resource is valid or not. For this to work, Kubernetes API-server needs to trust the CA certificate that is used to sign the admission webhook’s TLS certificate.

  1. Generate a certificate for admission webhook.

    You can either use a self-signed certificate or a Kubernetes CA. The CN field of the x509 certificate takes the form <validation-service-name>.<ingress-controller-namespace>.svc, which in the default case is kong-validation-webhook.kong.svc.

    • self-signed certificate

      Use openssl to generate a self-signed certificate:

      openssl req -x509 -newkey rsa:2048 -keyout tls.key -out tls.crt -days 365  \
      -nodes -subj "/CN=kong-validation-webhook.kong.svc" \
      -extensions EXT -config <( \
       printf "[dn]\nCN=kong-validation-webhook.kong.svc\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:kong-validation-webhook.kong.svc\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
      

      The results should look like this:

      Generating a 2048 bit RSA private key
      ..........................................................+++
      .............+++
      writing new private key to 'key.pem'
      
    • In-built Kubernetes CA Kubernetes comes with an in-built CA which can be used to provision a certificate for the admission webhook. For more information about generating a certificate using the in-built CA, see Managing TLS in a cluster.

  2. Create a Kubernetes secret object based on the key and certificate. The PEM-encoded certificate is stored in a file named tls.crt and private key is stored in tls.key.

    kubectl create secret tls kong-validation-webhook -n kong \
     --key tls.key --cert tls.crt
    

    The results should look like this:

    secret/kong-validation-webhook created
    
  3. Update the Ingress Controller deployment. Use this command to patch the Kong Ingress Controller deployment to mount the certificate and key pair and also enable the admission webhook.

     kubectl patch deploy -n kong ingress-kong \
     -p '{"spec":{"template":{"spec":{"containers":[{"name":"ingress-controller","env":[{"name":"CONTROLLER_ADMISSION_WEBHOOK_LISTEN","value":":8080"}],"volumeMounts":[{"name":"validation-webhook","mountPath":"/admission-webhook"}]}],"volumes":[{"secret":{"secretName":"kong-validation-webhook"},"name":"validation-webhook"}]}}}}'
    

    The results should look like this:

     deployment.extensions/ingress-kong patched
    

    If you are using the Helm chart, run helm upgrade -f <path to values.yamvl> <release name> kong/kong after enabling the webhook or updating the certificate configuration. Note that chart versions 2.16 and later enable the webhook by default.

  4. Enable the validating admission.

    If you are using Kubernetes CA to generate the certificate, you don’t need to supply a CA certificate (in the caBundle parameter) as part of the Validation Webhook configuration as the API-server already trusts the internal CA.

     readonly CABUNDLE=$(base64 < ./tls.crt)
     echo "apiVersion: admissionregistration.k8s.io/v1
     kind: ValidatingWebhookConfiguration
     metadata:
       name: kong-validations
     webhooks:
     - name: validations.kong.konghq.com
       objectSelector:
         matchExpressions:
         - key: owner
           operator: NotIn
           values:
           - helm
       failurePolicy: Ignore
       sideEffects: None
       admissionReviewVersions: [\"v1\", \"v1beta1\"]
       rules:
       - apiGroups:
         - configuration.konghq.com
         apiVersions:
         - '*'
         operations:
         - CREATE
         - UPDATE
         resources:
         - kongconsumers
         - kongconsumergroups
         - kongplugins
         - kongclusterplugins
         - kongingresses
       - apiGroups:
         - ''
         apiVersions:
         - 'v1'
         operations:
         - UPDATE
         resources:
         - secrets
       - apiGroups:
         - networking.k8s.io
         apiVersions:
           - 'v1'
         operations:
         - CREATE
         - UPDATE
         resources:
         - ingresses
       - apiGroups:
         - gateway.networking.k8s.io
         apiVersions:
         - 'v1alpha2'
         - 'v1beta1'
         operations:
         - CREATE
         - UPDATE
         resources:
         - gateways
         - httproutes
       clientConfig:
         service:
          namespace: kong
          name: kong-validation-webhook
        caBundle: ${CABUNDLE}" | kubectl apply -f -
    

    The results should look like this:

     validatingwebhookconfiguration.admissionregistration.k8s.io/kong-validations configured
    

Test the configuration

You can test if the admission webhook is enabled for duplicate KongConsumers, incorrect KongPlugins, incorrect credential secrets, and incorrect routes.

Verify duplicate KongConsumers

  1. Create a KongConsumer with username as alice:

     echo "apiVersion: configuration.konghq.com/v1
     kind: KongConsumer
     metadata:
       name: alice
       annotations:
         kubernetes.io/ingress.class: kong
     username: alice" | kubectl apply -f -
    

    The results should look like this:

     kongconsumer.configuration.konghq.com/alice created
    
  2. Create another KongConsumer with the same username:

     echo "apiVersion: configuration.konghq.com/v1
     kind: KongConsumer
     metadata:
       name: alice2
       annotations:
         kubernetes.io/ingress.class: kong
     username: alice" | kubectl apply -f -
    

    The results should look like this:

     Error from server: error when creating "STDIN": admission webhook "validations.kong.konghq.com" denied the request: consumer already exists
    

The validation webhook rejected the KongConsumer resource as there already exists a consumer in Kong with the same username.

Verify incorrect KongPlugins

Try to create the following KongPlugin resource. The foo config property does not exist in the configuration definition and hence the admission webhook returns back an error. If you remove the foo: bar configuration line, the plugin will be created successfully.

echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: request-id
config:
  foo: bar
  header_name: my-request-id
plugin: correlation-id
" | kubectl apply -f -

The results should look like this:

Error from server: error when creating "STDIN": admission webhook "validations.kong.konghq.com" denied the request: 400 Bad Request {"fields":{"config":{"foo":"unknown field"}},"name":"schema violation","code":2,"message":"schema violation (config.foo: unknown field)"}

Verify incorrect credential secrets

With 0.7 and later versions of Kong Ingress Controller, validations also take place for incorrect secret types and wrong parameters to the secrets.

kubectl create secret generic missing-password-credential \
  --from-literal=kongCredType=basic-auth \
  --from-literal=username=foo

The results should look like this:

Error from server: admission webhook "validations.kong.konghq.com" denied the request: missing required field(s): password
kubectl create secret generic wrong-cred-credential \
  --from-literal=kongCredType=wrong-auth \
  --from-literal=sdfkey=my-sooper-secret-key

The results should look like this:

Error from server: admission webhook "validations.kong.konghq.com" denied the request: invalid credential type: wrong-auth

Verify incorrect routes

In versions 2.12 and later, the controller validates route definitions

echo 'apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: echo
  annotations:
    konghq.com/strip-path: "true"
spec:
  ingressClassName: kong
  rules:
    - http:
        paths:
          - path: /~/echo/**/broken
            pathType: ImplementationSpecific
            backend:
              service:
                name: echo
                port:
                  number: 1025' | kubectl apply -f -

The results should look like this:

Error from server: error when creating "STDIN": admission webhook "validations.kong.konghq.com" denied the request: Ingress failed schema validation: schema violation (paths.1: invalid regex: '/echo/**/broken' (PCRE returned: pcre_compile() failed: nothing to repeat in "/echo/**/broken" at "*/broken"))
Thank you for your feedback.
Was this page useful?
情報が多すぎる場合 close cta icon
Kong Konnectを使用すると、より多くの機能とより少ないインフラストラクチャを実現できます。月額1Mリクエストが無料。
無料でお試しください
  • Kong
    APIの世界を動かす

    APIマネジメント、サービスメッシュ、イングレスコントローラーの統合プラットフォームにより、開発者の生産性、セキュリティ、パフォーマンスを大幅に向上します。

    • 製品
      • Kong Konnect
      • Kong Gateway Enterprise
      • Kong Gateway
      • Kong Mesh
      • Kong Ingress Controller
      • Kong Insomnia
      • 製品アップデート
      • 始める
    • ドキュメンテーション
      • Kong Konnectドキュメント
      • Kong Gatewayドキュメント
      • Kong Meshドキュメント
      • Kong Insomniaドキュメント
      • Kong Konnect Plugin Hub
    • オープンソース
      • Kong Gateway
      • Kuma
      • Insomnia
      • Kongコミュニティ
    • 会社概要
      • Kongについて
      • お客様
      • キャリア
      • プレス
      • イベント
      • お問い合わせ
  • 利用規約• プライバシー• 信頼とコンプライアンス
© Kong Inc. 2025