zoukankan      html  css  js  c++  java
  • OpenShift helm的安装

    1.安装过程

    下载addons的代码

    $ git clone https://github.com/jorgemoralespou/minishift-addons
    $ cd minishift-addons

    因为helm的tiller要求访问gcr的地址,必然被墙,因此把地址替换成ericnie2017/tiller:latest 后建立

    ericdeMacBook-Pro:helm ericnie$ cat helm.addon
    # Name: helm
    # Description: Installs helm
    
    # Pull the image
    echo "pull start"
    docker pull lachlanevenson/k8s-helm:v2.8.1
    
    echo "deploy start"
    # Deploy helm
    docker run --rm -v /home/docker:/root:z -v /var/lib/minishift/openshift.local.config:/var/lib/minishift/openshift.local.config:z --net=host --env KUBECONFIG=/var/lib/minishift/openshift.local.config/master/admin.kubeconfig --env HELM_HOST=localhost:8443 lachlanevenson/k8s-helm:v2.8.1 init --upgrade -i ericnie2017/tiller:latest  --skip-refresh
    
    echo "deploy finish"
    
    # Create serviceaccounts and add the permissions to it. Then make the deployment use it
    oc create serviceaccount helm -n kube-system
    oc patch deployment/tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccountName":"helm"}}}}' -n kube-system
    oc adm policy add-cluster-role-to-user cluster-admin -z helm -n kube-system
    
    # Expose helm as nodePort
    oc expose deployment/tiller-deploy --target-port=tiller --type=NodePort --name=tiller -n kube-system
    ericdeMacBook-Pro:add-ons ericnie$ minishift addons install helm
    Addon 'helm' installed
    ericdeMacBook-Pro:add-ons ericnie$ minishift addons apply helm
    -- Applying addon 'helm':
    "pull start".
    "deploy start".
    "deploy finish"....
    Add into your ~/.bashrc this lines:
    
      eval "$(minishift oc-env)"
      export HELM_HOST="$(minishift ip):$(oc get svc/tiller -o jsonpath='{.spec.ports[0].nodePort}' -n kube-system --as=system:admin)"
      export MINISHIFT_ADMIN_CONTEXT="default/$(oc config view -o jsonpath='{.contexts[?(@.name=="minishift")].context.cluster}')/system:admin"
    
    Initialize the helm client, if not done already
    
    e.g.
      helm init -c
    
    Search for an application:
    
    e.g.
      helm search
    
    And now deploy an application
    
    e.g.
      helm version
    
    To delete helm tiller
      oc delete sa/helm deployment/tiller-deploy svc/tiller -n kube-system --as=system:admin

    以admin:admin登录后看到tiller部署成功

    2.客户端安装

    设置环境变量

    ericdeMacBook-Pro:~ ericnie$ export HELM_HOST="$(minishift ip):$(oc get svc/tiller -o jsonpath='{.spec.ports[0].nodePort}' -n kube-system --as=system:admin)"
    ericdeMacBook-Pro:~ ericnie$   export MINISHIFT_ADMIN_CONTEXT="default/$(oc config view -o jsonpath='{.contexts[?(@.name=="minishift")].context.cluster}')/system:admin"
    ericdeMacBook-Pro:~ ericnie$ echo $HELM_HOST
    192.168.99.100:30417
    ericdeMacBook-Pro:~ ericnie$ echo $MINISHIFT_ADMIN_CONTEXT
    default/192-168-99-100:8443/system:admin

    下载helm客户端

    去到网址,找到对应版本下载 

    https://github.com/helm/helm/releases?after=v2.8.0

    注意需要翻墙 :(

    https://storage.googleapis.com/kubernetes-helm/helm-v2.8.1-darwin-amd64.tar.gz

    下载然后解压,加入.bash_profile

    ericdeMacBook-Pro:~ ericnie$ cat .bash_profile
    export CLICOLOR=1
    #export PATH=/Users/ericnie/minishift/minishift-1.24.0-darwin-amd64:/Users/ericnie/minishift:$PATH
    #export PATH="/Users/ericnie/.minishift/cache/oc/v3.10.0/darwin:$PATH"
    
    export PATH=/Users/ericnie/bin:$PATH
    export PATH="/Users/ericnie/.minishift/cache/oc/v3.9.31/darwin:/Users/ericnie/minishift/helm/darwin-amd64:$PATH"
    
    export MINISHIFT_USERNAME=eric.nie@163.com
    export MINISHIFT_PASSWORD=Welcome1$
    ericdeMacBook-Pro:~ ericnie$ helm version
    Client: &version.Version{SemVer:"v2.8.1", GitCommit:"6af75a8fd72e2aa18a2b278cfe5c7a1c5feca7f2", GitTreeState:"clean"}
    Server: &version.Version{SemVer:"v2.8.1", GitCommit:"6af75a8fd72e2aa18a2b278cfe5c7a1c5feca7f2", GitTreeState:"clean"}

    能连上server,会显示server的版本

    3.验证

    helm create hello-svc

    然后把deployment.yaml, service.yaml和values.yaml修改掉

    ericdeMacBook-Pro:hello-svc ericnie$ cat templates/deployment.yaml
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: {{.Values.deployment_name}}
    spec:
      replicas: {{.Values.replicas}}
      template:
        metadata:
          labels:
            tomcat-app: {{.Values.deployment_name}}
            version: "1"
        spec:
          containers:
          - name: {{.Values.deployment_name}}
            image: 172.30.1.1:5000/s2i-tomcat/openshift-tomcat:{{.Values.imageversion}}
            ports:
            - containerPort: {{.Values.port}}
              name: tomcatport
    ericdeMacBook-Pro:hello-svc ericnie$ cat templates/service.yaml
    apiVersion: v1
    kind: Service
    metadata:
      name: {{.Values.service_name}}
      labels:
        tomcat-app: hellotomcat
    spec:
      ports:
      - port: {{.Values.port}}
        protocol: TCP
        targetPort: 8080
        name: http
      type: NodePort
      selector:
        tomcat-app: hellotomcat
    ericdeMacBook-Pro:hello-svc ericnie$ cat values.yaml
    replicas: 1
    deployment_name: hellotomcat
    service_name: hellotomcat
    port: 8080
    imageversion: latest

    然后安装

    ericdeMacBook-Pro:hello-svc ericnie$ helm install ./ --namespace s2i-tomcat
    NAME:   austere-mastiff
    LAST DEPLOYED: Sat Oct 13 11:12:06 2018
    NAMESPACE: s2i-tomcat
    STATUS: DEPLOYED
    
    RESOURCES:
    ==> v1/Service
    NAME         TYPE      CLUSTER-IP      EXTERNAL-IP  PORT(S)         AGE
    hellotomcat  NodePort  172.30.214.212  <none>       8080:30982/TCP  1s
    
    ==> v1beta1/Deployment
    NAME         DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
    hellotomcat  1        0        0           0          0s

    4.遇到的问题

    minishift ip无法出来

    ricdeMacBook-Pro:helm ericnie$ minishift ip
    Error getting IP: ssh command error:
    command : ip addr show
    err     : exit status 255
    output  :

     之前遇到过几次,每次状况不一样,这次重新启动以后就可以了。

  • 相关阅读:
    zabbix中文配置指南(转)-服务器监控
    Native Fullscreen JavaScript API (plus jQuery plugin)
    浅谈 HTML5 的 DOM Storage 机制 (转)
    How to Customize Server Header using NginX headers-more module
    编译安装nginx并修改版本头信息—参考实例
    nginx 去掉服务器版本和名称和nginx_status 状态说明
    修改NGINX版本名称为任意WEB SERVER
    php加速缓存Xcache的安装与配置
    nginx-rrd监控nginx访问数
    Egret3D初步笔记二 (Unity导出场景使用)
  • 原文地址:https://www.cnblogs.com/ericnie/p/9781281.html
Copyright © 2011-2022 走看看