Skip to content

Latest commit

 

History

History
188 lines (132 loc) · 5.78 KB

development.md

File metadata and controls

188 lines (132 loc) · 5.78 KB

Development Guide

Table of Contents

This document is the canonical source of truth for things like supported toolchain versions for building TKE.

Please submit an [issue] on Github if you

  • Notice a requirement that this doc does not capture.
  • Find a different doc that specifies requirements (the doc should instead link here).

Requirements

TKE development helper scripts assume an up-to-date GNU tools environment. Recent Linux distros should work out-of-the-box.

macOS ships with outdated BSD-based tools. We recommend installing [macOS GNU tools].

Note that Mingw64/Cygwin on Windows is not supported yet.

If you don't have Git-LFS installed, see Git-LFS for instructions on how to install on different operating systems.

Go

TKE's backend is written in Go. If you don't have a Go development environment, please set one up.

TKE requires Go
0.8-0.12 1.12.5
1.0+ 1.13.3

TKE uses go modules to manage dependencies.

Once you have set up your golang development environment, make sure the environment variables contains:

go env -w GOPRIVATE="tkestack.io,tkestack.com,helm.sh,go.etcd.io,k8s.io,go.uber.org"

Node.js

TKE's frontend is written in Typescript. To bundle TKE's frontend code, you need a Node.js and NPM execution environment, please set one up.

TKE requires Node.js requires NPM
0.8-0.12 9.4+ 5.6+
1.0+ 10.3+ 6.1+

Clone source code

# Clone the repository on your machine
git clone [email protected]:tkestack/tke.git

# If you don't have a SSH key, feel free to clone using HTTPS instead
# git clone https://github.com/tkestack/tke.git

Building binary

The following section is a quick start on how to build TKE on a local OS/shell environment.

make build

The best way to validate your current setup is to build a small part of TKE. This way you can address issues without waiting for the full build to complete. To build a specific part of TKE use the BINS environment variable to let the build scripts know you want to build only a certain package/executable.

make build BINS=${package_you_want}
make build BINS="${package_you_want_1} ${package_you_want_2}"

Note: This applies to all top level folders under tke/cmd.

So for the tke-gateway, you can run:

make build BINS=tke-gateway

If everything checks out you will have an executable in the _output/{platform} directory to play around with.

Note: If you are using CDPATH, you must either start it with a leading colon, or unset the variable. The make rules and scripts to build require the current directory to come first on the CD search path in order to properly navigate between directories.

cd ${working_dir}/tke
make

To build binaries for multiple platforms:

make build.multiarch

To build a specific os/arch of TKE use the PLATFORMS environment variable to let the build scripts know you want to build only for os/arch.

make build.multiarch PLATFORMS="linux_amd64 windows_amd64 darwin_amd64"

Building docker image

In a production environment, it is recommended to run the TKE components in the Kubernetes cluster. TKE will build and push the image to the Docker Hub after each release.

If you don't have docker installed, see here for instructions on how to install on different operating systems.

If you need to build a container image locally, you can simply execute the instructions:

make image

If you want to build a container image of just one or more components, you can use IMAGES variables to control:

make image IMAGES=${package_you_want}
make image IMAGES="${package_you_want_1} ${package_you_want_2}"

Note: This applies to all top level folders under build/docker (except build/docker/tools).

So for the tke-platform-api, you can run:

make image IMAGES=tke-platform-api

To build container images for multiple platforms (i.e., linux_amd64 and linux_arm64), type:

make image.multiarch

Above all make image commands will use experimental features of Docker daemon (i.e. docker build --platform). Please refer to docker build docs to enable experimental features.

To build a specific os/arch for TKE container images, please use the PLATFORMS environment variable to let the build scripts know which os/arch you want to build.

make image.multiarch PLATFORMS="linux_amd64 linux_arm64"

Releasing docker image

Below is a quick start on how to push TKE container images to docker hub.

make push

TKEStack manages docker images via manifests and manifest lists. Please make sure you enable experimental features in the Docker client. You can find more details in docker manifest docs.

For more functions of other components, please see here. To run tke system locally, please see here.