-
Notifications
You must be signed in to change notification settings - Fork 105
feat(gateway): Distroless image #5581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lena-larionova
wants to merge
4
commits into
main
Choose a base branch
from
feat/os-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,6 +197,7 @@ dict | |
| dicts | ||
| digitalocean | ||
| discovery_support | ||
| distroless | ||
| dlp | ||
| DN | ||
| dns | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| --- | ||
| title: Install {{site.base_gateway}} using the distroless image | ||
| description: Run {{site.base_gateway}} from the distroless Docker image, which contains only the {{site.base_gateway}} runtime and its dependencies with no shell or package manager. | ||
| content_type: how_to | ||
| breadcrumbs: | ||
| - /gateway/ | ||
| - /gateway/install/ | ||
| permalink: /gateway/install/docker-distroless/ | ||
| related_resources: | ||
| - text: Install {{site.base_gateway}} on a supported platform | ||
| url: /gateway/install/ | ||
| - text: Install {{site.base_gateway}} using Docker Compose | ||
| url: /gateway/install/docker/ | ||
| - text: Install {{site.base_gateway}} in read-only mode | ||
| url: /gateway/install/docker-read-only/ | ||
| - text: Build your own custom Docker image | ||
| url: /how-to/build-custom-docker-image/ | ||
|
|
||
| products: | ||
| - gateway | ||
|
|
||
| works_on: | ||
| - on-prem | ||
| - konnect | ||
| min_version: | ||
| gateway: '3.15' | ||
|
|
||
| tldr: | ||
| q: How do I run {{site.base_gateway}} using the distroless image? | ||
| a: | | ||
| Pull `kong/kong-gateway:{{site.data.gateway_latest.ee-version}}-distroless` and run it with configuration passed via environment variables. | ||
| The distroless image has no shell, so you must configure {{site.base_gateway}} at container startup. | ||
|
|
||
| prereqs: | ||
| skip_product: true | ||
| inline: | ||
| - title: Docker | ||
| content: | | ||
| This guide requires [Docker](https://docs.docker.com/get-started/get-docker/) installed on your system. | ||
| - title: Kong license | ||
| content: | | ||
| Set your {{site.base_gateway}} license as an environment variable: | ||
| ```sh | ||
| export KONG_LICENSE_DATA='<your-license-json>' | ||
| ``` | ||
|
|
||
| faqs: | ||
| - q: Why use the distroless image? | ||
| a: | | ||
| The distroless image contains only the {{site.base_gateway}} runtime and its dependencies. | ||
| It has no shell, package manager, or OS tooling, which reduces the image's attack surface and can simplify security scanning. | ||
| - q: Can I get a shell inside the distroless container? | ||
| a: | | ||
| No. The distroless image has no shell. | ||
| Use environment variables or mounted config files to configure {{site.base_gateway}} instead of running commands inside the container. | ||
| - q: Is there a FIPS-compliant distroless image? | ||
| a: | | ||
| Yes. Pull `kong/kong-gateway:{{site.data.gateway_latest.ee-version}}-distroless-fips` and set `KONG_FIPS=on`. | ||
| See [FIPS support](/gateway/fips-support/) for additional configuration requirements. | ||
|
|
||
| - q: Can I run the distroless image with a database? | ||
| a: | | ||
| Yes. The distroless image supports the same deployment modes as other {{site.base_gateway}} images. | ||
| This guide uses [DB-less mode](/gateway/db-less-mode/), which requires no separate database container. | ||
|
|
||
| If you need a database-backed deployment, start a Postgres container first and run `kong migrations bootstrap` before starting the Gateway. | ||
| See [Install {{site.base_gateway}} using Docker Compose](/gateway/install/docker/) for a database-backed example. | ||
|
|
||
| tags: | ||
| - install | ||
| - docker | ||
|
|
||
| automated_tests: false | ||
| --- | ||
|
|
||
| ## Pull the distroless image | ||
|
|
||
| Pull the {{site.base_gateway}} distroless image from Docker Hub: | ||
|
|
||
| ```sh | ||
| docker pull kong/kong-gateway:{{ site.data.gateway_latest.ee-version }}-distroless | ||
| ``` | ||
|
|
||
| The distroless image is available for `linux/amd64` and `linux/arm64`. | ||
| Docker pulls the correct variant automatically based on your host architecture. | ||
|
|
||
| ## Create a Docker network | ||
|
|
||
| Create a dedicated network for {{site.base_gateway}}: | ||
|
|
||
| ```sh | ||
| docker network create kong-net | ||
| ``` | ||
|
|
||
| ## Create a declarative configuration file | ||
|
|
||
| In [DB-less mode](/gateway/db-less-mode/), you provide your Gateway configuration in a YAML file at startup. | ||
|
|
||
|
|
||
| Create a directory for your Kong configuration: | ||
|
|
||
| ```sh | ||
| mkdir -p declarative | ||
| ``` | ||
|
|
||
| Then, create a `kong.yml` file with your entire Gateway configuration. For example, the following file creates a Service and a Route: | ||
|
|
||
| ```yaml | ||
| cat <<EOF > declarative/kong.yml | ||
| _format_version: "3.0" | ||
| services: | ||
| - name: example-service | ||
| url: http://httpbin.konghq.com | ||
| routes: | ||
| - name: example-route | ||
| paths: | ||
| - /anything | ||
| protocols: | ||
| - http | ||
| - https | ||
| EOF | ||
| ``` | ||
|
|
||
| ## Start {{site.base_gateway}} | ||
|
|
||
| Run the distroless container, mounting the declarative configuration file and passing all settings via environment variables: | ||
|
|
||
| ```sh | ||
| docker run -d \ | ||
| --name kong-distroless \ | ||
| --network kong-net \ | ||
| -v "$(pwd)/declarative:/kong/declarative" \ | ||
| -e KONG_DATABASE=off \ | ||
| -e KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml \ | ||
| -e KONG_PROXY_ACCESS_LOG=/dev/stdout \ | ||
| -e KONG_PROXY_ERROR_LOG=/dev/stderr \ | ||
| -e KONG_ADMIN_ACCESS_LOG=/dev/stdout \ | ||
| -e KONG_ADMIN_ERROR_LOG=/dev/stderr \ | ||
| -e KONG_ADMIN_LISTEN="0.0.0.0:8001" \ | ||
| -e KONG_LICENSE_DATA="$KONG_LICENSE_DATA" \ | ||
| -p 8000:8000 \ | ||
| -p 8001:8001 \ | ||
| kong/kong-gateway:{{ site.data.gateway_latest.ee-version }}-distroless | ||
| ``` | ||
|
|
||
| {:.info} | ||
| > Because the distroless image has no shell, all {{site.base_gateway}} configuration must be passed as [environment variables (`KONG_*`)](/gateway/manage-kong-conf/#environment-variables) or in a mounted `kong.conf` file. | ||
| > You **cannot** run `kong` commands inside the container after it starts. | ||
|
|
||
| ## Validate | ||
|
|
||
| First, check that {{site.base_gateway}} is running by checking port 8000: | ||
|
|
||
| <!--vale off--> | ||
| {% control_plane_request %} | ||
| url: '/services' | ||
| method: GET | ||
| status_code: 200 | ||
| {% endcontrol_plane_request %} | ||
| <!--vale on--> | ||
|
|
||
| You should get a `200` response with a list of Gateway Services. | ||
|
|
||
| Then, access a configured Route through the proxy URL on port 8001: | ||
|
|
||
| {% validation request-check %} | ||
| url: /anything | ||
| status_code: 200 | ||
| {% endvalidation %} | ||
|
|
||
| This should return an `200` response, this time with the results from your Route. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.