kubernetes 1.7.5上安裝fabric8

參考鏈接:
https://fabric8.io/
https://github.com/fabric8io

1. 下載gofabric8

地址:https://github.com/fabric8io/gofabric8/releases
通過(guò)測(cè)試的版本 version:0.4.157

2. fabric8安裝需要使用pvc,所以配置StorageClass ,使用nfs

參考:http://blog.xianshiyue.com/216

3. 安裝gofabric8

mkdir $HOME/.fabric8/bin
cp gofabric8-linux-amd64 gofabric8-linux-amd64
mv gofabric8-linux-amd64 gofabric8
export PATH=$PATH:$HOME/.fabric8/bin

4. 開(kāi)始部署fabric8

gofabric8 deploy -y -d xianshiyue.com --namespace=fabric8

部署的過(guò)程中注意查看運(yùn)行的pods,有些鏡像下載很慢可以手動(dòng)下載,可以去阿里云下載,然后 docker tag
https://dev.aliyun.com/list.html?namePrefix=kube

5. 給 fabric8 命令空間下的 serviceaccount 授權(quán)

檢查pods 的運(yùn)行狀態(tài)都是running,但是還是無(wú)法訪(fǎng)問(wèn),檢查pods 的日志,發(fā)現(xiàn) exposecontroller,configmapcontroller 無(wú)權(quán)訪(fǎng)問(wèn)kubernetes 的api, 我自己用了一個(gè)粗暴的方式,給命令空間下所有的 serviceaccount 授權(quán),包括 default
eg:

kubectl create clusterrolebinding exposecontroller-cluster-admin-binding --clusterrole=cluster-admin --serviceaccount=fabric8:exposecontroller

kubectl create clusterrolebinding configmapcontroller-cluster-admin-binding --clusterrole=cluster-admin --serviceaccount=fabric8:configmapcontroller

kubectl create clusterrolebinding default-cluster-admin-binding --clusterrole=cluster-admin --serviceaccount=fabric8:default

kubectl create clusterrolebinding fabric8-cluster-admin-binding --clusterrole=cluster-admin --serviceaccount=fabric8:fabric8

6. 修改deployment ingress-nginx 的配置

6.1 導(dǎo)出yaml配置文件

kubectl get deployments ingress-nginx  -nfabric8 -o yaml >> ingress-nginx.yaml

6.2 修改配置文件

把pods網(wǎng)絡(luò)模式設(shè)置成 host,只需要添加 hostNetwork: true
eg:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    configmap.fabric8.io/update-on-change: nginx-config
    deployment.kubernetes.io/revision: "3"
    fabric8.io/git-branch: release-v2.2.311
    fabric8.io/git-commit: 2b9f7ce19493fe6d18392ac4f4be16f5e1a76fa3
    fabric8.io/iconUrl: https://cdn.rawgit.com/fabric8io/fabric8-devops/master/ingress-nginx/src/main/fabric8/icon.png
    fabric8.io/metrics-path: dashboard/file/kubernetes-pods.json/?var-project=ingress-nginx&var-version=2.2.311
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"extensions/v1beta1","kind":"Deployment","metadata":{"annotations":{"configmap.fabric8.io/update-on-change":"nginx-config","deployment.kubernetes.io/revision":"2","fabric8.io/git-branch":"release-v2.2.311","fabric8.io/git-commit":"2b9f7ce19493fe6d18392ac4f4be16f5e1a76fa3","fabric8.io/iconUrl":"https://cdn.rawgit.com/fabric8io/fabric8-devops/master/ingress-nginx/src/main/fabric8/icon.png","fabric8.io/metrics-path":"dashboard/file/kubernetes-pods.json/?var-project=ingress-nginx\u0026var-version=2.2.311"},"creationTimestamp":"2017-10-23T14:45:38Z","generation":2,"labels":{"group":"io.fabric8.devops.apps","project":"ingress-nginx","provider":"fabric8","version":"2.2.311"},"name":"ingress-nginx","namespace":"fabric8","resourceVersion":"3294","selfLink":"/apis/extensions/v1beta1/namespaces/fabric8/deployments/ingress-nginx","uid":"d5bb1ec8-b800-11e7-a179-00163e0c10a2"},"spec":{"replicas":1,"selector":{"matchLabels":{"group":"io.fabric8.devops.apps","project":"ingress-nginx","provider":"fabric8"}},"strategy":{"rollingUpdate":{"maxSurge":1,"maxUnavailable":1},"type":"RollingUpdate"},"template":{"metadata":{"annotations":{"configmap.fabric8.io/update-on-change":"nginx-config","fabric8.io/git-branch":"release-v2.2.311","fabric8.io/git-commit":"2b9f7ce19493fe6d18392ac4f4be16f5e1a76fa3","fabric8.io/iconUrl":"https://cdn.rawgit.com/fabric8io/fabric8-devops/master/ingress-nginx/src/main/fabric8/icon.png","fabric8.io/metrics-path":"dashboard/file/kubernetes-pods.json/?var-project=ingress-nginx\u0026var-version=2.2.311"},"creationTimestamp":null,"labels":{"group":"io.fabric8.devops.apps","project":"ingress-nginx","provider":"fabric8","version":"2.2.311"}},"spec":{"containers":[{"args":["-v=3","-nginx-configmaps=fabric8-system/nginx-config"],"env":[{"name":"FABRIC8_NGINX_CONFIG_CONFIGMAP","value":"client-max-body-size=2000m;proxy-connect-timeout=500s;proxy-read-timeout=500s;server-names-hash-bucket-size=256;server-names-hash-max-size=1024"}],"image":"nginxdemos/nginx-ingress:0.3.1","imagePullPolicy":"IfNotPresent","name":"nginx-ingress","ports":[{"containerPort":80,"hostPort":80,"name":"http","protocol":"TCP"},{"containerPort":443,"hostPort":443,"name":"https","protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File"}],"dnsPolicy":"ClusterFirst","hostNetwork":true,"nodeSelector":{"fabric8.io/externalIP":"true"},"restartPolicy":"Always","schedulerName":"default-scheduler","securityContext":{},"terminationGracePeriodSeconds":30}}},"status":{"availableReplicas":1,"conditions":[{"lastTransitionTime":"2017-10-23T14:45:38Z","lastUpdateTime":"2017-10-23T14:45:38Z","message":"Deployment has minimum availability.","reason":"MinimumReplicasAvailable","status":"True","type":"Available"}],"observedGeneration":2,"readyReplicas":1,"replicas":1,"updatedReplicas":1}}
  creationTimestamp: 2017-10-23T14:45:38Z
  generation: 3
  labels:
    group: io.fabric8.devops.apps
    project: ingress-nginx
    provider: fabric8
    version: 2.2.311
  name: ingress-nginx
  namespace: fabric8
  resourceVersion: "3872"
  selfLink: /apis/extensions/v1beta1/namespaces/fabric8/deployments/ingress-nginx
  uid: d5bb1ec8-b800-11e7-a179-00163e0c10a2
spec:
  replicas: 1
  selector:
    matchLabels:
      group: io.fabric8.devops.apps
      project: ingress-nginx
      provider: fabric8
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      annotations:
        configmap.fabric8.io/update-on-change: nginx-config
        fabric8.io/git-branch: release-v2.2.311
        fabric8.io/git-commit: 2b9f7ce19493fe6d18392ac4f4be16f5e1a76fa3
        fabric8.io/iconUrl: https://cdn.rawgit.com/fabric8io/fabric8-devops/master/ingress-nginx/src/main/fabric8/icon.png
        fabric8.io/metrics-path: dashboard/file/kubernetes-pods.json/?var-project=ingress-nginx&var-version=2.2.311
      creationTimestamp: null
      labels:
        group: io.fabric8.devops.apps
        project: ingress-nginx
        provider: fabric8
        version: 2.2.311
    spec:
      containers:
      - args:
        - -v=3
        - -nginx-configmaps=fabric8/nginx-config
        image: nginxdemos/nginx-ingress:0.3.1
        imagePullPolicy: IfNotPresent
        name: nginx-ingress
        ports:
        - containerPort: 80
          hostPort: 80
          name: http
          protocol: TCP
        - containerPort: 443
          hostPort: 443
          name: https
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      hostNetwork: true             ##=> 添加這一行
      nodeSelector:
        fabric8.io/externalIP: "true"
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 1
  conditions:
  - lastTransitionTime: 2017-10-23T14:45:38Z
    lastUpdateTime: 2017-10-23T14:45:38Z
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  observedGeneration: 3
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1

6.3 刪除原來(lái)的deployment, 應(yīng)用修改后的配置

kubectl delete -f ingress-nginx.yaml
kubectl create -f ingress-nginx.yaml

這個(gè)時(shí)候訪(fǎng)問(wèn) 配置的域名 http://xianshiyue.com 已經(jīng)可以成功進(jìn)入到控制臺(tái)了

7. 最后修改 ingress-nginx 的configmap

如果域名配置太長(zhǎng)的話(huà),service自動(dòng)生成域名部署到nginx中將會(huì)報(bào)錯(cuò),按照下圖修改就OK

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容