Upgrade Consul API gateway for Kubernetes
Since Consul v1.15, the Consul API gateway is a native feature within the Consul binary and is installed during the normal Consul installation process. Since Consul on Kubernetes v1.2 (Consul v1.16), the CRDs necessary for using the Consul API gateway for Kubernetes are also included. You can install Consul v1.16 using the Consul Helm chart v1.2 and later. Refer to Install API gateway for Kubernetes for additional information.
Introduction
Because Consul API gateway releases as part of Consul, it no longer has an independent version number. Instead, the API gateway inherits the same version number as the Consul binary. Refer to the release notes for additional information.
To begin using the native API gateway, complete one of the following upgrade paths:
Upgrade from Consul on Kubernetes v1.1.x
- Complete the instructions for upgrading to the native Consul API gateway.
Upgrade from v0.4.x - v0.5.x
- Complete the standard upgrade instructions
- Complete the instructions for upgrading to the native Consul API gateway.
Upgrade from v0.3.x
- Complete the instructions for upgrading to v0.4.0
- Complete the standard upgrade instructions
- Complete the instructions for upgrading to the native Consul API gateway.
Upgrade from v0.2.x
- Complete the instructions for upgrading to v0.3.0
- Complete the instructions for upgrading to v0.4.0
- Complete the standard upgrade instructions
- Complete the instructions for upgrading to the native Consul API gateway.
Upgrade from v0.1.x
- Complete the instructions for upgrading to v0.2.0
- Complete the instructions for upgrading to v0.3.0
- Complete the instructions for upgrading to v0.4.0
- Complete the standard upgrade instructions
- Complete the instructions for upgrading to the native Consul API gateway.
Upgrade to native Consul API gateway
You must begin the upgrade procedure with API gateway with Consul on Kubernetes v1.1 installed. If you are currently using a version of Consul on Kubernetes older than v1.1, complete the necessary stages of the upgrade path to v1.1 before you begin upgrading to the native API gateway. Refer to the Introduction for an overview of the upgrade paths.
Consul-managed CRDs
If you are able to tolerate downtime for your applications, you should delete previously installed CRDs and allow Consul to install and manage them for future updates. The amount of downtime depends on how quickly you are able to install the new version of Consul. If you are unable to tolerate any downtime, refer to Self-managed CRDs for instructions on how to upgrade without downtime.
Run the
kubectl delete
command and reference thekustomize
directory to delete the existing CRDs. The following example deletes the CRDs that were installed with API gatewayv0.5.1
:Issue the following command to use the API gateway packaged in Consul. Since Consul will not detected an external CRD, it will try to install the API gateway packaged with Consul.
Create
ServiceIntentions
allowingGateways
to communicate with any backend services that they route to. Refer to Service intentions configuration entry reference for additional information.Change any existing
Gateways
to reference the newGatewayClass
consul
. Refer to gatewayClass for additional information.After updating all of your
gateway
configurations to use the new controller, you can remove theapiGateway
block from the Helm chart and upgrade your Consul cluster. This completely removes the old gateway controller.values.yaml
Self-managed CRDs
Note
This upgrade method uses connectInject.apiGateway.manageExternalCRDs
, which was introduced in Consul on Kubernetes v1.2. As a result, you must be on at least Consul on Kubernetes v1.2 for this upgrade method.
If you are unable to tolerate any downtime, you can complete the following steps to upgrade to the native Consul API gateway. If you choose this upgrade option, you must continue to manually install the CRDs necessary for operating the API gateway.
Create a Helm chart that installs the version of Consul API gateway that ships with Consul and disables externally-managed CRDs:
values.yamlYou must set
connectInject.apiGateway.manageExternalCRDs
tofalse
. If you have external CRDs with legacy installation and you do not set this, you will get an error when you try to upgrade because Helm will try to install CRDs that already exist.Issue the following command to install the new version of API gateway and disables externally-managed CRDs:
Create
ServiceIntentions
allowingGateways
to communicate with any backend services that they route to. Refer to Service intentions configuration entry reference for additional information.Change any existing
Gateways
to reference the newGatewayClass
consul
. Refer to gatewayClass for additional information.After updating all of your
gateway
configurations to use the new controller, you can remove theapiGateway
block from the Helm chart and upgrade your Consul cluster. This completely removes the old gateway controller.values.yaml
Upgrade to v0.4.0
Consul API Gateway v0.4.0 adds support for Gateway API v0.5.0 and the following resources:
The graduated v1beta1
GatewayClass
,Gateway
andHTTPRoute
resources.The
ReferenceGrant
resource, which replaces the identicalReferencePolicy
resource.
Consul API Gateway v0.4.0 is backward-compatible with existing ReferencePolicy
resources, but we will remove support for ReferencePolicy
resources in a future release. We recommend that you migrate to ReferenceGrant
after upgrading.
Requirements
Ensure that the following requirements are met prior to upgrading:
- Consul API Gateway should be running version v0.3.0.
Procedure
Complete the standard upgrade.
After completing the upgrade, complete the post-upgrade configuration changes. The post-upgrade procedure describes how to replace your
ReferencePolicy
resources withReferenceGrant
resources and how to upgrade yourGatewayClass
,Gateway
, andHTTPRoute
resources from v1alpha2 to v1beta1.
Post-upgrade configuration changes
Complete the following steps after performing standard upgrade procedure.
Requirements
- Consul API Gateway should be running version v0.4.0.
- Consul Helm chart should be v0.47.0 or later.
- You should have the ability to run
kubectl
CLI commands. kubectl
should be configured to point to the cluster containing the installation you are upgrading.- You should have the following permissions for your Kubernetes cluster:
Gateway.read
ReferenceGrant.create
(Added in Consul Helm chart v0.47.0)ReferencePolicy.delete
Procedure
Verify the current version of the
consul-api-gateway-controller
Deployment
:You should receive a response similar to the following:
Issue the following command to get all
ReferencePolicy
resources across all namespaces.If you have any active
ReferencePolicy
resources, you will receive output similar to the response below.If your output is empty, upgrade your
GatewayClass
,Gateway
andHTTPRoute
resources to v1beta1 as described in step 7.For each
ReferencePolicy
in the source YAML files, change thekind
field toReferenceGrant
. You can optionally update themetadata.name
field or filename if they include the term "policy". In the following example, thekind
andmetadata.name
fields and filename have been changed to reflect the new resource. Note that updating thekind
field prevents you from using thekubectl edit
command to edit the remote state directly.referencegrant.yamlFor each file, apply the updated YAML to your cluster to create a new
ReferenceGrant
resource.Check to confirm that each new
ReferenceGrant
was created successfully.Finally, delete each corresponding old
ReferencePolicy
resource. Because replacementReferenceGrant
resources have already been created, there should be no interruption in the availability of any referencedService
orSecret
.For each
GatewayClass
,Gateway
, andHTTPRoute
in the source YAML, update theapiVersion
field togateway.networking.k8s.io/v1beta1
. Note that updating theapiVersion
field prevents you from using thekubectl edit
command to edit the remote state directly.For each file, apply the updated YAML to your cluster to update the existing
GatewayClass
,Gateway
orHTTPRoute
resources.
Upgrade to v0.3.0 from v0.2.0 or lower
Consul API Gateway v0.3.0 introduces a change for people upgrading from lower versions. Gateways with listeners
with a certificateRef
defined in a different namespace now require a ReferencePolicy
that explicitly allows Gateways
from the gateway's namespace to use certificateRef
in the certificateRef
's namespace.
Requirements
Ensure that the following requirements are met prior to upgrading:
- Consul API Gateway should be running version v0.2.1 or lower.
- You should have the ability to run
kubectl
CLI commands. kubectl
should be configured to point to the cluster containing the installation you are upgrading.- You should have the following permission rights on your Kubernetes cluster:
- (Optional) The jq command line processor for JSON can be installed, which will ease gateway retrieval during the upgrade process.
Procedure
Verify the current version of the
consul-api-gateway-controller
Deployment
:You should receive a response similar to the following:
Retrieve all gateways that have a
certificateRefs
in a different namespace. If you have installed thejq
utility, you can skip to step 4. Otherwise, issue the following command to get allGateways
across all namespaces:If you have any active
Gateways
, you will receive output similar to the following response. The output has been truncated to show only relevant fields:Inspect the
certificateRefs
entries for each of the routes.If a
namespace
field is not defined in thecertificateRefs
or if the namespace matches the namespace of the parentGateway
, then no additional action is required for thecertificateRefs
. Otherwise, note thenamespace
field values forcertificateRefs
configurations with anamespace
field that do not match the namespace of the parentGateway
. You must also note thenamespace
of the parent gateway. You will need these to create aReferencePolicy
that explicitly allows each cross-namespace certificateRefs-to-gateway pair. (see step 5).After completing this step, you will have a list of all secrets similar to the following:
Proceed with the standard-upgrade if your list is empty.
If you have installed
jq
, issue the following command to get allGateways
and filter for secrets that require aReferencePolicy
.The output will resemble the following response if gateways that require a new
ReferencePolicy
are returned:If your output is empty, proceed with the standard-upgrade.
Using the list of secrets you created earlier as a guide, create a
ReferencePolicy
to allow each gateway cross namespace secret access. TheReferencePolicy
explicitly allows each cross-namespace gateway to secret pair. TheReferencePolicy
must be created in the samenamespace
as thecertificateRefs
.Skip to the next step if you've already created a
ReferencePolicy
.The following example
ReferencePolicy
enablesexample-gateway
ingateway-namespace
to utilizecertificateRefs
in thecertificate-namespace
namespace:referencepolicy.yamlIf you have already created a
ReferencePolicy
, modify it to allow your gateway to access yourcertificateRef
and save it asreferencepolicy.yaml
. Note that eachReferencePolicy
only supports oneto
field and onefrom
field (refer theReferencePolicy
documentation). As a result, you may need to create multipleReferencePolicy
s.Issue the following command to apply it to your cluster:
Repeat this step as needed until each of your cross-namespace
certificateRefs
have a correspondingReferencePolicy
.Proceed with the standard-upgrade.
Upgrade to v0.2.0
Consul API Gateway v0.2.0 introduces a change for people upgrading from Consul API Gateway v0.1.0. Routes with a backendRef
defined in a different namespace now require a ReferencePolicy
that explicitly allows traffic from the route's namespace to the backendRef
's namespace.
Requirements
Ensure that the following requirements are met prior to upgrading:
- Consul API Gateway should be running version v0.1.0.
- You should have the ability to run
kubectl
CLI commands. kubectl
should be configured to point to the cluster containing the installation you are upgrading.- You should have the following permission rights on your Kubernetes cluster:
- (Optional) The jq command line processor for JSON can be installed, which will ease route retrieval during the upgrade process.
Procedure
Verify the current version of the
consul-api-gateway-controller
Deployment
:You should receive the following response:
Retrieve all routes that have a backend in a different namespace. If you have installed the
jq
utility, you can skip to step 4. Otherwise, issue the following command to get allHTTPRoutes
andTCPRoutes
across all namespaces:Note that the command only retrieves
HTTPRoutes
andTCPRoutes
.TLSRoutes
andUDPRoutes
are not supported in v0.1.0.If you have any active
HTTPRoutes
orTCPRoutes
, you will receive output similar to the following response. The output has been truncated to show only relevant fields:Inspect the
backendRefs
entries for each of the routes.If a
namespace
field is not defined in thebackendRef
or if the namespace matches the namespace of the route, then no additional action is required for thebackendRef
. Otherwise, note thegroup
,kind
,name
, andnamespace
field values forbackendRef
configurations that have anamespace
defined that do not match the namespace of the parent route. You must also note thekind
andnamespace
of the parent route. You will need these to create aReferencePolicy
that explicitly allows each cross-namespace route-to-service pair (see step 5).After completing this step, you will have a list of all routes similar to the following:
Proceed with standard-upgrade if your list is empty.
If you have installed
jq
, issue the following command to get allHTTPRoutes
andTCPRoutes
and filter for routes that require aReferencePolicy
.Note that the command retrieves all
HTTPRoutes
andTCPRoutes
.TLSRoutes
andUDPRoutes
are not supported in v0.1.0.The output will resemble the following response if routes that require a new
ReferencePolicy
are returned:If your output is empty, proceed with the standard-upgrade.
Using the list of routes you created earlier as a guide, create a
ReferencePolicy
to allow cross namespace traffic for each route service pair. TheReferencePolicy
explicitly allows each cross-namespace route to service pair. TheReferencePolicy
must be created in the samenamespace
as the backendService
.Skip to the next step if you've already created a
ReferencePolicy
.The following example
ReferencePolicy
enablesHTTPRoute
traffic from theexample-namespace
to Kubernetes Services in theweb-backend
namespace:referencepolicy.yamlIf you have already created a
ReferencePolicy
, modify it to allow your route and save it asreferencepolicy.yaml
. Note that eachReferencePolicy
only supports oneto
field and onefrom
field (refer theReferencePolicy
documentation). As a result, you may need to create multipleReferencePolicy
s.Issue the following command to apply it to your cluster:
Repeat this step as needed until each of your cross-namespace routes have a corresponding
ReferencePolicy
.Proceed with the standard-upgrade.
Standard Upgrade
Note: When you see VERSION
in examples of commands or configuration settings, replace VERSION
with the version number of the release you are installing, like 0.2.0
. If there is a lower case "v" in front of VERSION
the version number needs to follow the "v" as is v0.2.0
Requirements
Ensure that the following requirements are met prior to upgrading:
- You should have the ability to run
kubectl
CLI commands. kubectl
should be configured to point to the cluster containing the installation you are upgrading.
Procedure
This is the upgrade path to use when there are no version specific steps to take.
Issue the following command to install the new version of CRDs into your cluster:
Update
apiGateway.image
invalues.yaml
:values.yamlIssue the following command to upgrade your Consul installation:
Note that the upgrade will cause the Consul API Gateway controller shut down and restart with the new version.
According to the Kubernetes Gateway API specification, Gateway Class configurations should only be applied to a gateway upon creation. To see the effects on preexisting gateways after upgrading your CRD installation, delete and recreate any gateways by issuing the following commands:
(Optional) Delete and recreate your routes. Note that it may take several minutes for attached routes to reconcile and start reporting bind errors.
Post-Upgrade Configuration Changes
No additional configuration changes are required for this upgrade.