Changing The Kubernetes Package Repository

This page explains how to enable a package repository for the desired Kubernetes minor release upon upgrading a cluster. This is only needed for users of the community-owned package repositories hosted at pkgs.k8s.io. Unlike the legacy package repositories, the community-owned package repositories are structured in a way that there’s a dedicated package repository for each Kubernetes minor version.

Note: This guide only covers a part of the Kubernetes upgrade process. Please see the upgrade guide for more information about upgrading Kubernetes clusters.

Note: This step is only needed upon upgrading a cluster to another minor release. If you’re upgrading to another patch release within the same minor release (e.g. v1.29.5 to v1.29.7), you don’t need to follow this guide. However, if you’re still using the legacy package repositories, you’ll need to migrate to the new community-owned package repositories before upgrading (see the next section for more details on how to do this).

Before you begin

This document assumes that you’re already using the community-owned package repositories (pkgs.k8s.io). If that’s not the case, it’s strongly recommended to migrate to the community-owned package repositories as described in the official announcement.

Note: The legacy package repositories (apt.kubernetes.io and yum.kubernetes.io) have been deprecated and frozen starting from September 13, 2023. Using the new package repositories hosted at pkgs.k8s.io is strongly recommended and required in order to install Kubernetes versions released after September 13, 2023. The deprecated legacy repositories, and their contents, might be removed at any time in the future and without a further notice period. The new package repositories provide downloads for Kubernetes versions starting with v1.24.0.

Verifying if the Kubernetes package repositories are used

If you’re unsure whether you’re using the community-owned package repositories or the legacy package repositories, take the following steps to verify:

Print the contents of the file that defines the Kubernetes apt repository:

  1. # On your system, this configuration file could have a different name
  2. pager /etc/apt/sources.list.d/kubernetes.list

If you see a line similar to:

  1. deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /

You’re using the Kubernetes package repositories and this guide applies to you. Otherwise, it’s strongly recommended to migrate to the Kubernetes package repositories as described in the official announcement.

Print the contents of the file that defines the Kubernetes yum repository:

  1. # On your system, this configuration file could have a different name
  2. cat /etc/yum.repos.d/kubernetes.repo

If you see a baseurl similar to the baseurl in the output below:

  1. [kubernetes]
  2. name=Kubernetes
  3. baseurl=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/
  4. enabled=1
  5. gpgcheck=1
  6. gpgkey=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key
  7. exclude=kubelet kubeadm kubectl

You’re using the Kubernetes package repositories and this guide applies to you. Otherwise, it’s strongly recommended to migrate to the Kubernetes package repositories as described in the official announcement.

Print the contents of the file that defines the Kubernetes zypper repository:

  1. # On your system, this configuration file could have a different name
  2. cat /etc/zypp/repos.d/kubernetes.repo

If you see a baseurl similar to the baseurl in the output below:

  1. [kubernetes]
  2. name=Kubernetes
  3. baseurl=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/
  4. enabled=1
  5. gpgcheck=1
  6. gpgkey=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key
  7. exclude=kubelet kubeadm kubectl

You’re using the Kubernetes package repositories and this guide applies to you. Otherwise, it’s strongly recommended to migrate to the Kubernetes package repositories as described in the official announcement.

Note:

The URL used for the Kubernetes package repositories is not limited to pkgs.k8s.io, it can also be one of:

  • pkgs.k8s.io
  • pkgs.kubernetes.io
  • packages.kubernetes.io

Switching to another Kubernetes package repository

This step should be done upon upgrading from one to another Kubernetes minor release in order to get access to the packages of the desired Kubernetes minor version.

  1. Open the file that defines the Kubernetes apt repository using a text editor of your choice:

    1. nano /etc/apt/sources.list.d/kubernetes.list

    You should see a single line with the URL that contains your current Kubernetes minor version. For example, if you’re using v1.28, you should see this:

    1. deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /
  2. Change the version in the URL to the next available minor release, for example:

    1. deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /
  3. Save the file and exit your text editor. Continue following the relevant upgrade instructions.

  4. Open the file that defines the Kubernetes yum repository using a text editor of your choice:

    1. nano /etc/yum.repos.d/kubernetes.repo

    You should see a file with two URLs that contain your current Kubernetes minor version. For example, if you’re using v1.28, you should see this:

    1. [kubernetes]
    2. name=Kubernetes
    3. baseurl=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/
    4. enabled=1
    5. gpgcheck=1
    6. gpgkey=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key
    7. exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
  5. Change the version in these URLs to the next available minor release, for example:

    1. [kubernetes]
    2. name=Kubernetes
    3. baseurl=https://pkgs.k8s.io/core:/stable:/vv1.29/rpm/
    4. enabled=1
    5. gpgcheck=1
    6. gpgkey=https://pkgs.k8s.io/core:/stable:/vv1.29/rpm/repodata/repomd.xml.key
    7. exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
  6. Save the file and exit your text editor. Continue following the relevant upgrade instructions.

What’s next