在 minikube 上部署 knative

本文涉及的产品
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
图片翻译,图片翻译 100张
语种识别,语种识别 100万字符
简介: 在 minikube 上部署 knative 流程简介。

安装 minkube

// 部署 minkube
$ minikube start --image-mirror-country cn \
    --iso-url=https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.5.0.iso \
    --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers \
    --container-runtime=containerd \
    --vm-driver=virtualbox \
    --kubernetes-version='v1.17.0' \
    --network-plugin=cni \
    --memory=5120 \
    --cpus=4 \
    --alsologtostderr -v=8

// 安装 cilium 网络查件
$ kubectl create -f https://raw.githubusercontent.com/cilium/cilium/v1.8/install/kubernetes/quick-install.yaml

// 检查 pod 是否正常运行
$ kubectl get pod -n kube-system
NAME                               READY   STATUS    RESTARTS   AGE
cilium-crs5s                       1/1     Running   0          3h40m
cilium-operator-69c684d865-77c9w   1/1     Running   0          3h40m
coredns-7f9c544f75-47x56           1/1     Running   0          3h41m
coredns-7f9c544f75-g95kk           1/1     Running   0          3h41m
etcd-minikube                      1/1     Running   0          3h41m
kube-addon-manager-minikube        1/1     Running   0          3h41m
kube-apiserver-minikube            1/1     Running   0          3h41m
kube-controller-manager-minikube   1/1     Running   0          3h41m
kube-proxy-59zdn                   1/1     Running   0          3h41m
kube-scheduler-minikube            1/1     Running   0          3h41m
storage-provisioner                1/1     Running   0          3h41m

安装 istio

// 下载 istioctl bin 文件
$ curl -L https://istio.io/downloadIstio | sh -

// 使用 istioctl 安装 istio 组件
$ cp istio-1.5.0/bin/istioctl /usr/local/bin/

$ cat << EOF > ./istio-minimal-operator.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
  values:
    global:
      proxy:
        autoInject: enabled  // 自动注入 istio sidecar
      useMCP: false
      # The third-party-jwt is not enabled on all k8s.
      # See: https://istio.io/docs/ops/best-practices/security/#configure-third-party-service-account-tokens
      jwtPolicy: first-party-jwt

  addonComponents:
    pilot:
      enabled: true
    prometheus:
      enabled: false

  components:
    ingressGateways:
      - name: istio-ingressgateway
        enabled: true
      - name: cluster-local-gateway
        enabled: true
        label:
          istio: cluster-local-gateway
          app: cluster-local-gateway
        k8s:
          service:
            type: ClusterIP
            ports:
            - port: 15020
              name: status-port
            - port: 80
              name: http2
            - port: 443
              name: https
EOF

$ istioctl manifest apply -f istio-minimal-operator.yaml

安装 knative

// 安装 knative operator
$ kubectl apply -f https://github.com/knative/operator/releases/download/v0.15.0/operator.yaml

// 创建 Knative Serving CR,创建完成后,knative operator 会自动安装 knative 所需要的组件
$ cat <<-EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
 name: knative-serving
---
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: knative-serving
  namespace: knative-serving
EOF

// 检查 knative-serving 组件是否正常运行
$ kubectl get deployment -n knative-serving
NAME               READY   UP-TO-DATE   AVAILABLE   AGE
activator          1/1     1            1           3h25m
autoscaler         1/1     1            1           3h25m
autoscaler-hpa     1/1     1            1           3h25m
controller         1/1     1            1           3h25m
istio-webhook      1/1     1            1           3h25m
networking-istio   1/1     1            1           3h25m
webhook            1/1     1            1           3h25m


// 创建 knative-eventing cr
$ cat <<-EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
 name: knative-eventing
---
apiVersion: operator.knative.dev/v1alpha1
kind: KnativeEventing
metadata:
  name: knative-eventing
  namespace: knative-eventing
EOF

// 检查 knative-eventing 组件是否正常运行
$ kubectl get deployment -n knative-eventing
NAME                    READY   UP-TO-DATE   AVAILABLE   AGE
broker-controller       1/1     1            1           3h25m
broker-filter           1/1     1            1           3h25m
broker-ingress          1/1     1            1           3h25m
eventing-controller     1/1     1            1           3h25m
eventing-webhook        1/1     1            1           3h25m
imc-controller          1/1     1            1           3h25m
imc-dispatcher          1/1     1            1           3h25m
mt-broker-controller    1/1     1            1           3h25m
pingsource-mt-adapter   1/1     1            1           109m


// 为 knative-serving namespace 启用 istio sidecar 自动注入功能
$ kubectl label namespace knative-serving istio-injection=enabled

// 启用 Istio mTLS 功能
$ cat <<EOF | kubectl apply -f -
apiVersion: "security.istio.io/v1beta1"
kind: "PeerAuthentication"
metadata:
  name: "default"
  namespace: "knative-serving"
spec:
  mtls:
    mode: PERMISSIVE
EOF

// 安装 knative 客户端工具 kn,类似于 kubectl、istioctl 可以对 kantive 中的资源进行操作
$ curl https://storage.googleapis.com/knative-nightly/client/latest/kn-darwin-amd64
$ cp kn-darwin-amd64 /usr/local/bin/kn

检查 knative 服务状态

knative 服务所启动的 pod 分别在 knative-serving 和 knative-eventing 两个 namespace 下,查看 pod 是否都已启动成功:

$ kubectl get pod -n knative-serving
NAME                                READY   STATUS    RESTARTS   AGE
activator-7fff689bcb-zt9pm          2/2     Running   2          22d
autoscaler-5bcff95856-pr6nk         2/2     Running   1          22d
autoscaler-hpa-75584dd678-fpk7w     2/2     Running   1          22d
controller-bbdd78bc4-6cqm4          2/2     Running   1          22d
istio-webhook-5f5794dcc4-sgzlj      2/2     Running   1          22d
networking-istio-7d875675c7-gc55v   1/1     Running   0          22d
storage-version-migration-f46wc     1/2     Running   2          22d
webhook-68bb66b676-9xk4s            2/2     Running   7          22d

$ kubectl get pod -n knative-eventing
NAME                                     READY   STATUS      RESTARTS   AGE
broker-controller-5587985664-rrhsj       1/1     Running     0          22d
broker-filter-854c4dbd4d-ng75g           1/1     Running     2          22d
broker-ingress-bd8dd9fb8-6zqv2           1/1     Running     2          22d
eventing-controller-58db89b996-kbrsp     1/1     Running     0          22d
eventing-webhook-7dc8cc7798-sspfm        1/1     Running     5          22d
imc-controller-d88855db5-zj6h6           1/1     Running     0          22d
imc-dispatcher-549db764cc-8lbcj          1/1     Running     0          22d
mt-broker-controller-55b9857d8d-7hf6n    1/1     Running     0          22d
pingsource-mt-adapter-6b465cffdc-gqgn5   1/1     Running     0          22d
storage-version-migration-6mm74          0/1     Completed   0          22d
v0.15.0-upgrade-5vr8z                    0/1     Completed   0          22d

参考:

istio 安装:https://knative.dev/development/install/installing-istio/#installing-istio-with-sidecar-injection

目录
相关文章
|
12天前
|
Kubernetes Ubuntu Linux
我应该如何安装Kubernetes
我应该如何安装Kubernetes
|
3月前
|
存储 Kubernetes 容器
Kubernetes(K8S) kubesphere 安装
Kubernetes(K8S) kubesphere 安装
109 4
|
3月前
|
存储 Kubernetes API
Kubernetes(K8S) kubesphere 介绍
Kubernetes(K8S) kubesphere 介绍
110 2
|
3月前
|
Kubernetes Linux Docker
Kubernetes(K8S) helm 安装
Kubernetes(K8S) helm 安装
96 1
|
6月前
|
Kubernetes 关系型数据库 数据库
Kubernetes Helm
Kubernetes Helm
138 0
Kubernetes Helm
|
6月前
|
Kubernetes Linux Docker
Kubernetes详解(四)——基于kubeadm的Kubernetes部署
Kubernetes详解(四)——基于kubeadm的Kubernetes部署
175 2
|
运维 Kubernetes 监控
kubernetes 安装cilium
Cilium是一个开源软件,用于透明地提供和保护使用Kubernetes,Docker和Mesos等Linux容器管理平台部署的应用程序服务之间的网络和API连接。 Cilium基于一种名为BPF的新Linux内核技术,它可以在Linux内部动态插入强大的安全性,可见性和网络控制逻辑。 除了提供传统的网络级安全性之外,BPF的灵活性还可以在API和进程级别上实现安全性,以保护容器或容器内的通信。由于BPF在Linux内核中运行,因此可以应用和更新Cilium安全策略,而无需对应用程序代码或容器配置进行任何更改。
1021 1
|
运维 Kubernetes 监控
kubernetes(k8s)应用篇之 kubesphere
kubesphere在公司使用的介绍
808 1
|
弹性计算 Kubernetes 负载均衡
k8s初探-安装kubernetes
k8s初探-安装kubernetes
331 0
|
消息中间件 Kubernetes 网络协议
使用minikube安装kubernetes和dashboard
使用minikube安装kubernetes和dashboard
518 0
使用minikube安装kubernetes和dashboard
下一篇
无影云桌面