|
| 1 | +<!-- |
| 2 | + Copyright 2025 Google LLC |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | + --> |
| 16 | + |
| 17 | +# Installation |
| 18 | + |
| 19 | +There are 2 ways to install XPK: |
| 20 | + |
| 21 | +- via Python package installer (`pip`), |
| 22 | +- clone from git and build from source. |
| 23 | + |
| 24 | +## Prerequisites |
| 25 | + |
| 26 | +The following tools must be installed: |
| 27 | + |
| 28 | +- python >= 3.10: download from [here](https://www.python.org/downloads/) |
| 29 | +- pip: [installation instructions](https://pip.pypa.io/en/stable/installation/) |
| 30 | +- python venv: [installation instructions](https://virtualenv.pypa.io/en/latest/installation.html) |
| 31 | +(all three of above can be installed at once from [here](https://packaging.python.org/en/latest/guides/installing-using-linux-tools/#installing-pip-setuptools-wheel-with-linux-package-managers)) |
| 32 | +- gcloud: install from [here](https://cloud.google.com/sdk/gcloud#download_and_install_the) and then: |
| 33 | + - Run `gcloud init` |
| 34 | + - [Authenticate](https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login) to Google Cloud |
| 35 | +- kubectl: install from [here](https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#install_kubectl) and then: |
| 36 | + - Install `gke-gcloud-auth-plugin` from [here](https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#install_plugin) |
| 37 | +- docker: [installation instructions](https://docs.docker.com/engine/install/) and then: |
| 38 | + - Configure sudoless docker: [guide](https://docs.docker.com/engine/install/linux-postinstall/) |
| 39 | + - Run `gcloud auth configure-docker` to ensure images can be uploaded to registry |
| 40 | + |
| 41 | +### Additional prerequisites when installing from pip |
| 42 | + |
| 43 | +- kueuectl: install from [here](https://kueue.sigs.k8s.io/docs/reference/kubectl-kueue/installation/) |
| 44 | +- kjob: installation instructions [here](https://github.com/kubernetes-sigs/kjob/blob/main/docs/installation.md) |
| 45 | + |
| 46 | +### Additional prerequisites when installing from source |
| 47 | + |
| 48 | +- git: [installation instructions](https://git-scm.com/downloads/linux) |
| 49 | +- make: install by running `apt-get -y install make` (`sudo` might be required) |
| 50 | + |
| 51 | +### Additional prerequisites to enable bash completion |
| 52 | + |
| 53 | +- Install [argcomplete](https://pypi.org/project/argcomplete/) globally on your machine. |
| 54 | + ```shell |
| 55 | + pip install argcomplete |
| 56 | + activate-global-python-argcomplete |
| 57 | + ``` |
| 58 | +- Configure `argcomplete` for XPK. |
| 59 | + ```shell |
| 60 | + eval "$(register-python-argcomplete xpk)" |
| 61 | + ``` |
| 62 | + |
| 63 | +## Installation via pip |
| 64 | + |
| 65 | +To install XPK using pip, first install required tools mentioned in [prerequisites](#prerequisites) and [additional prerequisites](#additional-prerequisites-when-installing-from-pip). Then you can install XPK simply by running: |
| 66 | + |
| 67 | +```shell |
| 68 | +pip install xpk |
| 69 | +``` |
| 70 | + |
| 71 | +If you see an error saying: `This environment is externally managed`, please use a virtual environment. For example: |
| 72 | + |
| 73 | +```shell |
| 74 | +# One time step of creating the virtual environment |
| 75 | +VENV_DIR=~/venvp3 |
| 76 | +python3 -m venv $VENV_DIR |
| 77 | + |
| 78 | +# Activate your virtual environment |
| 79 | +source $VENV_DIR/bin/activate |
| 80 | + |
| 81 | +# Install XPK in virtual environment using pip |
| 82 | +pip install xpk |
| 83 | +``` |
| 84 | + |
| 85 | +## Installation from source |
| 86 | + |
| 87 | +To install XPK from source, first install required tools mentioned in [prerequisites](#prerequisites) and [additional prerequisites](#additional-prerequisites-when-installing-from-source). Afterwards you can install XPK from source using `make` |
| 88 | + |
| 89 | +```shell |
| 90 | +# Clone the XPK repository |
| 91 | +git clone https://github.com/google/xpk.git |
| 92 | +cd xpk |
| 93 | + |
| 94 | +# Install required dependencies and build XPK with make |
| 95 | +make install && export PATH=$PATH:$PWD/bin |
| 96 | +``` |
| 97 | + |
| 98 | +If you want the dependecies to be available in your PATH please run: `echo $PWD/bin` and add its value to `PATH` in .bashrc or .zshrc file. |
| 99 | + |
| 100 | +If you see an error saying: `This environment is externally managed`, please use a virtual environment. For example: |
| 101 | + |
| 102 | +```shell |
| 103 | +# One time step of creating the virtual environment |
| 104 | +VENV_DIR=~/venvp3 |
| 105 | +python3 -m venv $VENV_DIR |
| 106 | + |
| 107 | +# Activate your virtual environment |
| 108 | +source $VENV_DIR/bin/activate |
| 109 | + |
| 110 | +# Clone the XPK repository |
| 111 | +git clone https://github.com/google/xpk.git |
| 112 | +cd xpk |
| 113 | + |
| 114 | +# Install required dependencies and build XPK with make |
| 115 | +make install && export PATH=$PATH:$PWD/bin |
| 116 | +``` |
0 commit comments