AKS-Engine 是Azure 提供的开源K8S 部署包,通过自定义template 文件在Azure 上创建K8S集群。

Step1:安装 AKS-Engine

$ aks_version=v0.28.1
$ wget https://mirror.azure.cn/kubernetes/aks-engine/$aks_version/aks-engine-$aks_version-linux-amd64.tar.gz
$ tar -xvzf aks-engine-$aks_version-linux-amd64.tar.gz
$ alias aks-engine=‘`pwd`/aks-engine-$aks_version-linux-amd64/aks-engine’

Step2:创建 Service Principals

Service Principals 是Azure 上一种安全认证,用来认证服务是否能被调用。

$ az login
$ az account set --subscription="${SUBSCRIPTION_ID}"
$ az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/${SUBSCRIPTION_ID}

Step3 :生成 Azure Kubernetes Template

Template 用来定义kubernetes 的功能开启,比如网络插件,创建位置,权限等

具体可以参考: https://github.com/Azure/aks-engine/blob/master/docs/aksengine.md

$ k8s_version=1.11.5
$ mkdir kubernetes1115 && cd kubernetes1115
$ wget -O kubernetes-$k8s_version.json https://raw.githubusercontent.com/andyzhangx/Demo/master/acs-engine/mooncake/kubernetes-1.10.7.json
$ vi kubernetes-$k8s_version.json
"location": "chinaeast2",
 "dnsPrefix": "yute-k8s1115",
"vmSize": "Standard_NC6s_v3",
“keyData”:”rsa …”
"servicePrincipalProfile": {
            "clientId": "appID which get from step2",
            "secret": "password which get from step2"
        }
$ aks-engine generate kubernetes-$k8s_version.json

Step3.1(Optional) : 如果需要通过固定IP出入站,需要设置AKS-Engine 的load balance 为Stand Load Balance ,默认为Basic。

$ vi kubernetes-$k8s_version.json
    "properties": {
        "orchestratorProfile": {
            "orchestratorType": "Kubernetes",
            "orchestratorVersion": "1.11.5",
            "kubernetesConfig": {
                "loadBalancerSku": "standard"
            }
        },

 

Step4:创建 Azure Kubernetes

$ dnsPrefix=yute-k8s1115
$ vi _output/$dnsPrefix/azuredeploy.parameters.json
    "dockerEngineDownloadRepo": {
      "value": "https://mirror.azure.cn/docker-engine/apt/repo/"
    }
$ RESOURCE_GROUP_NAME=yute-k8s1115
$ az group create -l chinaeast2 -n $RESOURCE_GROUP_NAME
$ az group deployment create \
    --name="$dnsPrefix" \
    --resource-group=$RESOURCE_GROUP_NAME \
    --template-file="./_output/$dnsPrefix/azuredeploy.json" \
--parameters "@./_output/$dnsPrefix/azuredeploy.parameters.json"

Complete

Step5 :安装命令行Kubectl

$ scp azureuser@MASTERFQDN:.kube/config .
$ export KUBECONFIG=`pwd`/config
$ kubectl get nodes

Step6 : 启动Dashboard

$ kubectl proxy

通过浏览器访问 http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

转载于:https://www.cnblogs.com/mumusansmile/p/10595569.html

Logo

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

更多推荐