安装 kubectl

kubectl 用来访问 k8s

参考官方文档: https://kubernetes.io/docs/tasks/tools/install-kubectl/

主要步骤:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client

安装 k8s 环境

这里使用 minikube 安装 k8s 单机测试环境

参考官方文档: https://minikube.sigs.k8s.io/docs/start/

主要步骤:

  1. 安装 minikube
    curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm
    sudo rpm -ivh minikube-latest.x86_64.rpm
    
  2. 使用 minikube 安装 k8s 环境
    minikube start
    
  3. 验证
    kubectl get po -A
    
  4. 打开 kubernetes-dashboard web 页面 (非必须)
    minikube dashboard
    
  5. 命令补全(非必须)
    参考文档: https://minikube.sigs.k8s.io/docs/commands/completion/
    minikube completion bash > ~/minikube.completion.bash
    echo "source ~/minikube.completion.bash" > ~/.bashrc
    source ~/.bashrc
    

安装 istio

istio 官方有个入门教程,包括安装与使用 https://istio.io/latest/docs/setup/getting-started/

  1. 下载 Istio 包

    curl -L https://istio.io/downloadIstio | sh -
    

    执行完毕后,如下目录结构:

    [fananchong@qa3-haidao istio-1.8.3]$ tree -d -L 1
    .
    ├── bin
    ├── manifests
    ├── samples
    └── tools
    

    把 istio-1.8.3/bin 目录加到 PATH 内,方便直接使用istioctl工具

  2. istioctl 命令自动补全

    cp tools/istioctl.bash ~/
    echo "source ~/istioctl.bash" > ~/.bashrc
    
  3. 安装 istio

    istioctl install --set profile=demo -y
    
  4. 添加名称空间标签,以指示Istio在以后部署应用程序时自动注入Envoy sidecar代理

    kubectl label namespace default istio-injection=enabled
    

其他

清点下现在安装的工具有:

  • minikube
  • kubectl
  • istioctl

清点下当前 k8s 内的 pod :

[fananchong@qa3-haidao istio-1.8.3]$ kubectl get po -A
NAMESPACE              NAME                                        READY   STATUS    RESTARTS   AGE
istio-system           istio-egressgateway-578bb559f8-v5vb7        1/1     Running   0          3m43s
istio-system           istio-ingressgateway-854cb6bb9f-6sfdt       1/1     Running   0          3m43s
istio-system           istiod-6448599985-qmtmb                     1/1     Running   0          4m3s
kube-system            coredns-74ff55c5b-j2wz8                     1/1     Running   0          60m
kube-system            etcd-minikube                               1/1     Running   0          60m
kube-system            kube-apiserver-minikube                     1/1     Running   0          60m
kube-system            kube-controller-manager-minikube            1/1     Running   0          60m
kube-system            kube-proxy-x8vkq                            1/1     Running   0          60m
kube-system            kube-scheduler-minikube                     1/1     Running   0          60m
kube-system            storage-provisioner                         1/1     Running   1          60m
kubernetes-dashboard   dashboard-metrics-scraper-c95fcf479-tm4nd   1/1     Running   0          52m
kubernetes-dashboard   kubernetes-dashboard-6cff4c7c4f-vmv2f       1/1     Running   0          52m

清点下当前 k8s 内的 service :

[fananchong@qa3-haidao istio-1.8.3]$ kubectl get services -A
NAMESPACE              NAME                        TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                      AGE
default                kubernetes                  ClusterIP      10.96.0.1        <none>        443/TCP                                                                      64m
istio-system           istio-egressgateway         ClusterIP      10.97.119.18     <none>        80/TCP,443/TCP,15443/TCP                                                     7m35s
istio-system           istio-ingressgateway        LoadBalancer   10.107.141.248   <pending>     15021:30357/TCP,80:31419/TCP,443:31018/TCP,31400:30434/TCP,15443:30527/TCP   7m35s
istio-system           istiod                      ClusterIP      10.109.93.115    <none>        15010/TCP,15012/TCP,443/TCP,15014/TCP                                        7m56s
kube-system            kube-dns                    ClusterIP      10.96.0.10       <none>        53/UDP,53/TCP,9153/TCP                                                       64m
kubernetes-dashboard   dashboard-metrics-scraper   ClusterIP      10.106.21.146    <none>        8000/TCP                                                                     56m
kubernetes-dashboard   kubernetes-dashboard        ClusterIP      10.105.143.111   <none>        80/TCP                                                                       56m
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐