客户端安装
https://github.com/linkerd/linkerd2/releases/download/stable-2.11.1/linkerd2-cli-stable-2.11.1-linux-amd64mv linkerd2-cli-edge-xxxxx-linux-amd64 /usr/local/bin/linkerd
官网
https://linkerd.io/2.11/getting-started/#step-5-explore-linkerd
查看需要的镜像
[root@k8s-66 vm]# linkerd install --ignore-cluster | grep image: | sed -e 's/^ *//' | sort | uniqimage:image: cr.l5d.io/linkerd/controller:edge-22.2.2image: cr.l5d.io/linkerd/policy-controller:edge-22.2.2image: cr.l5d.io/linkerd/proxy:edge-22.2.2image: cr.l5d.io/linkerd/proxy-init:v1.5.2
默认安装
linkerd install | kubectl apply -f -
检查是否安装成功
[root@k8s-66 ~]# linkerd checklinkerd core checks===================kubernetes-api--------------√ can initialize the client√ can query the Kubernetes APIkubernetes-version------------------√ is running the minimum Kubernetes API version√ is running the minimum kubectl version
[root@k8s-66 ~]# kubectl get pods -n linkerdNAME READY STATUS RESTARTS AGElinkerd-destination-6bdfc99c5c-r6tg9 4/4 Running 0 20mlinkerd-identity-54795b9f9f-5khm5 2/2 Running 0 20mlinkerd-proxy-injector-564744b4d5-chltq 2/2 Running 0 20m
一个官网的demo
tee emojivoto.yml <<-'EOF'apiVersion: v1kind: Namespacemetadata: name: emojivoto---apiVersion: v1kind: ServiceAccountmetadata: name: emoji namespace: emojivoto---apiVersion: v1kind: ServiceAccountmetadata: name: voting namespace: emojivoto---apiVersion: v1kind: ServiceAccountmetadata: name: web namespace: emojivoto---apiVersion: v1kind: Servicemetadata: name: emoji-svc namespace: emojivotospec: ports: - name: grpc port: 8080 targetPort: 8080 - name: prom port: 8801 targetPort: 8801 selector: app: emoji-svc---apiVersion: v1kind: Servicemetadata: name: voting-svc namespace: emojivotospec: ports: - name: grpc port: 8080 targetPort: 8080 - name: prom port: 8801 targetPort: 8801 selector: app: voting-svc---apiVersion: v1kind: Servicemetadata: name: web-svc namespace: emojivotospec: ports: - name: http port: 80 targetPort: 8080 selector: app: web-svc type: ClusterIP---apiVersion: apps/v1kind: Deploymentmetadata: labels: app.kubernetes.io/name: emoji app.kubernetes.io/part-of: emojivoto app.kubernetes.io/version: v11 name: emoji namespace: emojivotospec: replicas: 1 selector: matchLabels: app: emoji-svc version: v11 template: metadata: labels: app: emoji-svc version: v11 spec: containers: - env: - name: GRPC_PORT value: "8080" - name: PROM_PORT value: "8801" image: docker.l5d.io/buoyantio/emojivoto-emoji-svc:v11 name: emoji-svc ports: - containerPort: 8080 name: grpc - containerPort: 8801 name: prom resources: requests: cpu: 100m serviceAccountName: emoji---apiVersion: apps/v1kind: Deploymentmetadata: labels: app.kubernetes.io/name: vote-bot app.kubernetes.io/part-of: emojivoto app.kubernetes.io/version: v11 name: vote-bot namespace: emojivotospec: replicas: 1 selector: matchLabels: app: vote-bot version: v11 template: metadata: labels: app: vote-bot version: v11 spec: containers: - command: - emojivoto-vote-bot env: - name: WEB_HOST value: web-svc.emojivoto:80 image: docker.l5d.io/buoyantio/emojivoto-web:v11 name: vote-bot resources: requests: cpu: 10m---apiVersion: apps/v1kind: Deploymentmetadata: labels: app.kubernetes.io/name: voting app.kubernetes.io/part-of: emojivoto app.kubernetes.io/version: v11 name: voting namespace: emojivotospec: replicas: 1 selector: matchLabels: app: voting-svc version: v11 template: metadata: labels: app: voting-svc version: v11 spec: containers: - env: - name: GRPC_PORT value: "8080" - name: PROM_PORT value: "8801" image: docker.l5d.io/buoyantio/emojivoto-voting-svc:v11 name: voting-svc ports: - containerPort: 8080 name: grpc - containerPort: 8801 name: prom resources: requests: cpu: 100m serviceAccountName: voting---apiVersion: apps/v1kind: Deploymentmetadata: labels: app.kubernetes.io/name: web app.kubernetes.io/part-of: emojivoto app.kubernetes.io/version: v11 name: web namespace: emojivotospec: replicas: 1 selector: matchLabels: app: web-svc version: v11 template: metadata: labels: app: web-svc version: v11 spec: containers: - env: - name: WEB_PORT value: "8080" - name: EMOJISVC_HOST value: emoji-svc.emojivoto:8080 - name: VOTINGSVC_HOST value: voting-svc.emojivoto:8080 - name: INDEX_BUNDLE value: dist/index_bundle.js image: docker.l5d.io/buoyantio/emojivoto-web:v11 name: web-svc ports: - containerPort: 8080 name: http resources: requests: cpu: 100m serviceAccountName: webEOF
kubectl -n emojivoto port-forward svc/web-svc 8080:80
访问http://localhost:8080 得到 好多Emojivoto
或者nodePort
[root@k8s-66 ~]# kubectl get svc -n emojivoto | grep web-svcweb-svc NodePort 10.101.237.10
准备网格准入
[root@k8s-66 ~]# kubectl get pods -n emojivoto NAME READY STATUS RESTARTS AGEemoji-5dbdd567bd-m7zww 1/1 Running 0 17mvote-bot-58b4f5fdb7-l82v9 1/1 Running 0 17mvoting-5fdcddcfc-dqwqq 1/1 Running 0 17mweb-677476dd8d-ghqfv 1/1 Running 0 3m57s
开始注入
kubectl get -n emojivoto deploy -o yaml | linkerd inject - | kubectl apply -f -
注入成功
官网
https://linkerd.io/2.11/tasks/using-a-private-docker-repository/