June 20-22 Announcing HashiConf Europe full schedule: keynotes, sessions, labs & more Register Now
  • Overview
    • Consul on Kubernetes
    • Control access with Consul API Gateway
    • Discover Services with Consul
    • Enforce Zero Trust Networking with Consul
    • Load Balancing with Consul
    • Manage Traffic with Consul
    • Multi-Platform Service Mesh with Consul
    • Network Infrastructure Automation with Consul
    • Observability with Consul
  • Enterprise
  • Tutorials
  • Docs
  • API
  • CLI
  • Community
GitHub
Download
Try HCP Consul
    • v1.12.x (latest)
    • v1.11.x
    • v1.10.x
    • v1.9.x
    • v1.8.x
    • Overview
      • Overview
      • What is a Service Mesh?
      • Overview
      • Chef, Puppet, etc.
      • Nagios
      • SkyDNS
      • SmartStack
      • Serf
      • Eureka
      • Istio
      • Envoy and Other Proxies
      • Custom Solutions
    • Overview
    • Manual Bootstrap
    • Consul Agent
    • Glossary
    • Required Ports
    • Bootstrapping a Datacenter
    • Cloud Auto-join
    • Server Performance
    • Kubernetes
  • API
  • Commands (CLI)
    • Register Services - Service Definitions
    • Find Services - DNS Interface
    • Monitor Services - Check Definitions
    • Overview
    • How Service Mesh Works
    • Configuration
      • Overview
      • Ingress Gateway
      • Mesh
      • Exported Services
      • Proxy Defaults
      • Service Defaults
      • Service Intentions
      • Service Resolver
      • Service Router
      • Service Splitter
      • Terminating Gateway
      • Overview
      • Envoy
      • Built-in Proxy
      • Proxy Integration
      • Managed (Deprecated)
      • Overview
      • Proxy Service Registration
      • Sidecar Service Registration
    • Service-to-service permissions - Intentions
    • Service-to-service permissions - Intentions (Legacy Mode)
    • Transparent Proxy
      • Overview
      • UI Visualization
      • Overview
      • Discovery Chain
    • Connectivity Tasks
    • Distributed Tracing
      • Overview
        • WAN Federation
        • Enabling Service-to-service Traffic Across Datacenters
        • Enabling Service-to-service Traffic Across Admin Partitions
      • Ingress Gateways
      • Terminating Gateways
    • Nomad
    • Kubernetes
      • Overview
      • Go Integration
      • Overview
      • Built-In CA
      • Vault
      • ACM Private CA
    • Develop and Debug
    • Security
    • Overview
    • Installation
    • Technical Specifications
    • Common Errors
    • Upgrades
    • Overview
    • Architecture
      • Installing Consul on Kubernetes
      • Installing Consul K8s CLI
        • Minikube
        • Kind
        • AKS (Azure)
        • EKS (AWS)
        • GKE (Google Cloud)
        • Red Hat OpenShift
        • Self Hosted Kubernetes
        • Consul Clients Outside Kubernetes
        • Consul Servers Outside Kubernetes
        • Single Consul Datacenter in Multiple Kubernetes Clusters
        • Consul Enterprise
        • Overview
        • Federation Between Kubernetes Clusters
        • Federation Between VMs and Kubernetes
        • Overview
        • Systems Integration
          • Overview
          • Bootstrap Token
          • Enterprise License
          • Gossip Encryption Key
          • Partition Token
          • Replication Token
          • Server TLS
          • Service Mesh Certificates
          • Snapshot Agent Config
        • WAN Federation
      • Compatibility Matrix
      • Overview
      • Transparent Proxy
      • Ingress Gateways
      • Terminating Gateways
      • Ingress Controllers
      • Configuring a Connect CA Provider
      • Health Checks
        • Metrics
    • Service Sync
      • Overview
      • Upgrade An Existing Cluster to CRDs
    • Annotations and Labels
    • Consul DNS
      • Upgrading Consul on Kubernetes
      • Upgrading Consul K8s CLI
      • Uninstall
      • Certificate Rotation
      • Gossip Encryption Key Rotation
      • Configure TLS on an Existing Cluster
      • Common Error Messages
      • FAQ
    • Helm Chart Configuration
    • Consul K8s CLI Reference
    • Overview
    • Requirements
    • Task Resource Usage
      • Installation
      • Secure Configuration
      • Migrate Existing Tasks
      • Installation
      • Secure Configuration
      • ACL Controller
    • Architecture
    • Consul Enterprise
    • Configuration Reference
    • Overview
      • Installation
      • Requirements
      • Configure
      • Run Consul-Terraform-Sync
    • Architecture
      • Overview
      • Status
      • Tasks
      • Overview
      • task
    • Configuration
    • Tasks
    • Terraform Modules
      • Overview
      • License
      • Terraform Cloud Driver
      • Overview
      • Terraform
      • Terraform Cloud
    • Compatibility
    • Consul KV
    • Sessions
    • Watches
    • Overview
      • General
      • CLI Reference
      • Configuration Reference
    • Configuration Entries
    • Telemetry
    • Sentinel
    • RPC
    • Overview
      • ACL System Overview
      • Tokens
      • Policies
      • Roles
      • Rules Reference
      • Legacy Mode
      • Token Migration
      • ACLs in Federated Datacenters
        • Overview
        • Kubernetes
        • JWT
        • OIDC
        • AWS IAM
    • Encryption
      • Overview
      • Core
      • Network Infrastructure Automation
    • Overview
    • Admin Partitions
    • Audit Logging
    • Automated Backups
    • Automated Upgrades
    • Enhanced Read Scalability
    • Single sign-on - OIDC
    • Redundancy Zones
    • Advanced Federation
    • Network Segments
    • Namespaces
    • NIA with TFE
    • Sentinel
      • Overview
      • FAQ
    • Overview
    • Improving Consul Resilience
    • Anti-Entropy
    • Consensus Protocol
    • Gossip Protocol
    • Jepsen Testing
    • Network Coordinates
    • Consul Integration Program
    • NIA Integration Program
    • Vault Integration
    • Proxy Integration
  • Consul Tools
    • Overview
    • Compatibility Promise
    • Specific Version Details
      • Overview
      • General Process
      • Upgrading to 1.2.4
      • Upgrading to 1.6.9
      • Upgrading to 1.8.13
      • Upgrading to 1.10.0
    • Common Error Messages
    • FAQ
    • Overview
      • v1.11.x
      • v1.10.x
      • v1.9.x
      • v0.1.x
      • v0.2.x
      • v0.4.x
      • v0.3.x
      • v0.2.x
      • v0.5.x
      • v0.6.0-beta
    • Overview
    • ACL
  • Guides
Type '/' to Search

»Upgrades

This topic describes how to upgrade Consul API Gateway.

»Breaking Changes

Consul API Gateway v0.2.0 introduces a breaking 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:
    • HTTPRoute.read
    • TCPRoute.read
    • ReferencePolicy.create
  • (Optional) The jq command line processor for JSON can be installed, which will ease route retrieval during the upgrade process.

»Procedure

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

  1. Verify the current version of the consul-api-gateway-controller Deployment:

    $ kubectl get deployment --namespace consul consul-api-gateway-controller --output=jsonpath= "{@.spec.template.spec.containers[?(@.name=='api-gateway-controller')].image}"
    
    $ kubectl get deployment --namespace consul consul-api-gateway-controller --output=jsonpath= "{@.spec.template.spec.containers[?(@.name=='api-gateway-controller')].image}"
    

    You should receive the following response:

    "hashicorp/consul-api-gateway:0.1.0"
    
    "hashicorp/consul-api-gateway:0.1.0"
    
  2. 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 all HTTPRoutes and TCPRoutes across all namespaces:

    $ kubectl get HTTPRoute,TCPRoute --output json --all-namespaces
    
    $ kubectl get HTTPRoute,TCPRoute --output json --all-namespaces
    

    Note that the command only retrieves HTTPRoutes and TCPRoutes. TLSRoutes and UDPRoutes are not supported in v0.1.0.

    If you have any active HTTPRoutes or TCPRoutes, you will receive output similar to the following response. The output has been truncated to show only relevant fields:

      apiVersion: v1
      items:
      - apiVersion: gateway.networking.k8s.io/v1alpha2
        kind: HTTPRoute
        metadata:
          name: example-http-route,
          namespace: example-namespace,
          ...
        spec:
          parentRefs:
          - group: gateway.networking.k8s.io
            kind: Gateway
            name: gateway
            namespace: gw-ns
          rules:
          - backendRefs:
            - group: ""
              kind: Service
              name: web-backend
              namespace: gateway-namespace
              ...
            ...
      - apiVersion: gateway.networking.k8s.io/v1alpha2
        kind: TCPRoute
        metadata:
          name: example-tcp-route,
          namespace: a-different-namespace,
          ...
        spec:
          parentRefs:
          - group: gateway.networking.k8s.io
            kind: Gateway
            name: gateway
            namespace: gateway-namespace
          rules:
          - backendRefs:
            - group: ""
              kind: Service
              name: web-backend
              namespace: gateway-namespace
              ...
        ...
    
      apiVersion: v1
      items:
      - apiVersion: gateway.networking.k8s.io/v1alpha2
        kind: HTTPRoute
        metadata:
          name: example-http-route,
          namespace: example-namespace,
          ...
        spec:
          parentRefs:
          - group: gateway.networking.k8s.io
            kind: Gateway
            name: gateway
            namespace: gw-ns
          rules:
          - backendRefs:
            - group: ""
              kind: Service
              name: web-backend
              namespace: gateway-namespace
              ...
            ...
      - apiVersion: gateway.networking.k8s.io/v1alpha2
        kind: TCPRoute
        metadata:
          name: example-tcp-route,
          namespace: a-different-namespace,
          ...
        spec:
          parentRefs:
          - group: gateway.networking.k8s.io
            kind: Gateway
            name: gateway
            namespace: gateway-namespace
          rules:
          - backendRefs:
            - group: ""
              kind: Service
              name: web-backend
              namespace: gateway-namespace
              ...
        ...
    
  3. Inspect the backendRefs entries for each of the routes.

    If a namespace field is not defined in the backendRef or if the namespace matches the namespace of the route, then no additional action is required for the backendRef. Otherwise, note the group, kind, name, and namespace field values for backendRef configurations that have a namespace defined that do not match the namespace of the parent route. You must also note the kind and namespace of the parent route. You will need these to create a ReferencePolicy that explicitly allows each cross-namespace route-to-service pair to prevent the route from breaking (see step 5).

    After completing this step, you will have a list of all routes similar to the following:

      example-http-route:
        - namespace: example-namespace
          kind: HTTPRoute
          backendReferences:
            - group : ""
              kind: Service
              name: web-backend
              namespace: gateway-namespace
    
      example-tcp-route:
        - namespace: a-different-namespace
          kind: HTTPRoute
          backendReferences:
            - group : ""
              kind: Service
              name: web-backend
              namespace: gateway-namespace
    
      example-http-route:
        - namespace: example-namespace
          kind: HTTPRoute
          backendReferences:
            - group : ""
              kind: Service
              name: web-backend
              namespace: gateway-namespace
    
      example-tcp-route:
        - namespace: a-different-namespace
          kind: HTTPRoute
          backendReferences:
            - group : ""
              kind: Service
              name: web-backend
              namespace: gateway-namespace
    

    Skip to step 8 if your list is empty.

  4. If you have installed jq, issue the following command to get all HTTPRoutes and TCPRoutes and filter for routes that require a ReferencePolicy.

    $ kubectl get HTTPRoute,TCPRoute -o json -A | jq -r '.items[] | {name: .metadata.name, namespace: .metadata.namespace, kind: .kind, crossNamespaceBackendReferences: ( .metadata.namespace as $parentnamespace | .spec.rules[] .backendRefs[] | select(.namespace != null and .namespace != $parentnamespace )  )} '
    
    $ kubectl get HTTPRoute,TCPRoute -o json -A | jq -r '.items[] | {name: .metadata.name, namespace: .metadata.namespace, kind: .kind, crossNamespaceBackendReferences: ( .metadata.namespace as $parentnamespace | .spec.rules[] .backendRefs[] | select(.namespace != null and .namespace != $parentnamespace )  )} '
    

    Note that the command retrieves all HTTPRoutes and TCPRoutes. TLSRoutes and UDPRoutes are not supported in v0.1.0.

    The output will resemble the following response if routes that require a new ReferencePolicy are returned:

    {
      "name": "example-http-route",
      "namespace": "example-namespace",
      "kind": "HTTPRoute",
      "crossNamespaceBackendReferences": {
        "group": "",
        "kind": "Service",
        "name": "web-backend",
        "namespace": "gateway-namespace",
        "port": 8080,
        "weight": 1
      }
    }
    {
      "name": "example-tcp-route",
      "namespace": "a-different-namespace",
      "kind": "TCPRoute",
      "crossNamespaceBackendReferences": {
        "group": "",
        "kind": "Service",
        "name": "web-backend",
        "namespace": "gateway-namespace",
        "port": 8080,
        "weight": 1
      }
    }
    
    {
      "name": "example-http-route",
      "namespace": "example-namespace",
      "kind": "HTTPRoute",
      "crossNamespaceBackendReferences": {
        "group": "",
        "kind": "Service",
        "name": "web-backend",
        "namespace": "gateway-namespace",
        "port": 8080,
        "weight": 1
      }
    }
    {
      "name": "example-tcp-route",
      "namespace": "a-different-namespace",
      "kind": "TCPRoute",
      "crossNamespaceBackendReferences": {
        "group": "",
        "kind": "Service",
        "name": "web-backend",
        "namespace": "gateway-namespace",
        "port": 8080,
        "weight": 1
      }
    }
    

    If your output is empty, skip to step 8.

  5. Using the list of routes you created earlier as a guide, create a ReferencePolicy to allow cross namespace traffic for each route service pair. The ReferencePolicy explicitly allows each cross-namespace route to service pair to prevent the route from breaking. The ReferencePolicy must be created in the same namespace as the backend Service.

    Skip to the next step if you've already created a ReferencePolicy.

    The following example ReferencePolicy enables HTTPRoute traffic from the example-namespace to Kubernetes Services in the web-backend namespace:

    apiVersion: gateway.networking.k8s.io/v1alpha2
    kind: ReferencePolicy
    metadata:
      name: reference-policy
      namespace: gateway-namespace
    spec:
      from:
        - group: gateway.networking.k8s.io
          kind: HTTPRoute
          namespace: example-namespace
      to:
        - group: ""
          kind: Service
          name: web-backend
    
    referencepolicy.yaml
    apiVersion: gateway.networking.k8s.io/v1alpha2
    kind: ReferencePolicy
    metadata:
      name: reference-policy
      namespace: gateway-namespace
    spec:
      from:
        - group: gateway.networking.k8s.io
          kind: HTTPRoute
          namespace: example-namespace
      to:
        - group: ""
          kind: Service
          name: web-backend
    
  6. If you have already created a ReferencePolicy, modify it to allow your route and save it as referencepolicy.yaml. Note that each ReferencePolicy only supports one to field and one from field (refer the ReferencePolicy documentation). As a result, you may need to create multiple ReferencePolicys.

  7. Issue the following command to apply it to your cluster:

    $ kubectl apply --filename referencepolicy.yaml
    
    $ kubectl apply --filename referencepolicy.yaml
    

    Repeat this step as needed until each of your cross-namespace routes have a corresponding ReferencePolicy.

  8. Issue the following command to install the new version of CRDs into your cluster:

    $ kubectl apply --kustomize="github.com/hashicorp/consul-api-gateway/config/crd?ref=vVERSION"
    
    $ kubectl apply --kustomize="github.com/hashicorp/consul-api-gateway/config/crd?ref=vVERSION"
    
  9. Update apiGateway.image in values.yaml:

    ...
    apiGateway:
      image: hashicorp/consul-api-gateway:VERSION
      ...
    
    values.yaml
    ...
    apiGateway:
      image: hashicorp/consul-api-gateway:VERSION
      ...
    
  10. Issue the following command to upgrade your Consul installation:

    $ helm upgrade --values values.yaml --namespace consul --version <NEW_VERSION> hashicorp/consul <DEPLOYMENT_NAME>
    
    $ helm upgrade --values values.yaml --namespace consul --version <NEW_VERSION> hashicorp/consul <DEPLOYMENT_NAME>
    

    Note that the upgrade will cause the Consul API Gateway controller shut down and restart with the new version.

  11. 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:

    $ kubectl delete --filename <path_to_gateway_config.yaml>
    $ kubectl create --filename <path_to_gateway_config.yaml>
    
    $ kubectl delete --filename <path_to_gateway_config.yaml>
    $ kubectl create --filename <path_to_gateway_config.yaml>
    
  12. (Optional) Delete and recreate your routes. Note that it may take several minutes for attached routes to reconcile and start reporting bind errors.

    $ kubectl delete --filename <path_to_route_config.yaml>
    $ kubectl create --filename <path_to_route_config.yaml>
    
    $ kubectl delete --filename <path_to_route_config.yaml>
    $ kubectl create --filename <path_to_route_config.yaml>
    

»Post-Upgrade Configuration Changes

No additional configuration changes are required for this upgrade.

github logoEdit this page
IntroGuidesDocsCommunityPrivacySecurityBrandConsent Manager