CLI를 설치하려면 아래 명령을 실행하여 설치 스크립트를 다운로드하고 로컬에서 실행합니다:
curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install-edge | sh
설치가 완료되면 실행 파일을 PATH 환경 변수에 추가하는 것을 잊지 마세요:
export PATH=$HOME/.linkerd2/bin:$PATH
설치 스크립트를 살펴보면 uname 명령으로 OS와 아키텍처를 식별한 뒤, 환경 변수를 활용해 GitHub에서 Linkerd 릴리스를 임시 디렉터리에 다운로드하는 것을 확인할 수 있습니다:
OS=$(uname -s)
arch=$(uname -m)
...
tmpdir=$(mktemp -d /tmp/linkerd2.XXXXXX)
srcfile="linkerd2-cli-${LINKERD2_VERSION}-${OS}"
if [ -n "${cli_arch}" ]; then
srcfile="${srcfile}-${cli_arch}"
fi
dstfile="${INSTALLROOT}/bin/linkerd-${LINKERD2_VERSION}"
url="https://github.com/linkerd/linkerd2/releases/download/${LINKERD2_VERSION}/${srcfile}"
3. CLI 탐색
CLI는 다양한 기능을 제공하며, 유지관리자들은 지속적으로 개선하고 있습니다. 사용 가능한 모든 명령은 linkerd help로 확인할 수 있습니다:
linkerd help
linkerd manages the Linkerd service mesh.
Usage:
linkerd [command]
Available Commands:
authz List authorizations for a resource
check Check the Linkerd installation for potential problems
completion Output shell completion code for the specified shell (bash, zsh or fish)
diagnostics Commands used to diagnose Linkerd components
help Help about any command
identity Display the certificate(s) of one or more selected pod(s)
inject Add the Linkerd proxy to a Kubernetes config
install Output Kubernetes configs to install Linkerd
install-cni Output Kubernetes configs to install Linkerd CNI
jaeger jaeger manages the jaeger extension of Linkerd service mesh
multicluster Manages the multicluster setup for Linkerd
profile Output service profile config for Kubernetes
prune Output extraneous Kubernetes resources in the linkerd control plane
uninject Remove the Linkerd proxy from a Kubernetes config
uninstall Output Kubernetes resources to uninstall Linkerd control plane
upgrade Output Kubernetes configs to upgrade an existing Linkerd control plane
version Print the client and server version information
viz viz manages the linkerd-viz extension of Linkerd service mesh
각 명령은 자체 하위 명령을 가지고 있습니다. linkerd <command> --help를 실행하면 확인할 수 있습니다. 예를 들어:
linkerd authz --help
List authorizations for a resource.
Usage:
linkerd authz [flags] resource
Flags:
-h, --help help for authz
-n, --namespace string Namespace of resource
Global Flags:
--api-addr string Override kubeconfig and communicate directly with the control plane at host:port (mostly for testing)
--as string Username to impersonate for Kubernetes operations
--as-group stringArray Group to impersonate for Kubernetes operations
--cni-namespace string Namespace in which the Linkerd CNI plugin is installed (default "linkerd-cni")
--context string Name of the kubeconfig context to use
--kubeconfig string Path to the kubeconfig file to use for CLI requests
-L, --linkerd-namespace string Namespace in which Linkerd is installed ($LINKERD_NAMESPACE) (default "linkerd")
--verbose Turn on debug logging
4. 클러스터에 Linkerd 설치
Linkerd를 설치하려면 먼저 제어 플레인에 필요한 CRD를 설치해야 합니다. API Gateway CRD, Linkerd CRD를 차례로 설치한 뒤, 제어 플레인을 설치합니다. linkerd install 명령은 YAML 매니페스트를 출력만 하므로, kubectl apply와 파이프해 적용해야 합니다.
참고: 2.18 이전 버전의 Linkerd는 자체 API Gateway 버전을 제공했지만, 0.7 버전에 고정되어 있어 Kong Gateway와 같은 타사 도구가 다른 버전을 요구할 때 문제가 있었습니다. 이를 해결하기 위해 2.18부터 Linkerd는 1.0.0 이상의 Gateway API 버전을 지원하며, 사용자가 별도로 설치해야 합니다. Linkerd 2.18 이전 버전에서 API Gateway 1.2.0을 실행하면 정책 컨트롤러가 특정 gRPCRoute Gateway API 버전을 감시하므로 제어 플레인이 동작하지 않습니다.