前提条件

已经部署完成并可运行kubernetes集群,如果没有请参考基于Vagrant CoreOS的kubernetes一键部署
需要注册Tectonic账号时提供的tectonic-license.

目前处于技术预览版,所有注册与使用都是免费的,但注册是必须提供信用卡信息。不会扣钱,当正式版本出来后会有通知,也不会直接扣款。注册地址,注册完成之后,官方将提供一个tectonic-preview-license.yaml证书文件.

部署Tectonic Services

  1. 下载Tectonic Services模板到本地。文件名为tectonic-services.yml。文件内容如下:
apiVersion: v1
kind: Namespace
metadata:
  name: tectonic-system
\---
apiVersion: v1
kind: ReplicationController
metadata:
  name: tectonic-manager
  namespace: tectonic-system
spec:
  replicas: 1
  selector:
    tectonic-app: manager
  template:
    metadata:
      labels:
        tectonic-app: manager
    spec:
      containers:
      \- command:
        - /tectonic-manager
        #coreos官方镜像仓库下载速度太慢,切换至hub.docker.com
        #image: quay.io/tectonic/manager:v0.4.1
        image: shenshouer/manager:v0.4.1
        name: tectonic-manager
        volumeMounts:
        - mountPath: /etc/tectonic-license/
          name: tectonic-license
      volumes:
      \- secret:
          secretName: tectonic-license
        name: tectonic-license

将其按功能分裂至两个个文件,起内容分别如下:
命名空间ns-tectonic-system.yaml:

apiVersion: v1
kind: Namespace
metadata:
  name: tectonic-system

rcrc-tectonic.yaml:

apiVersion: v1
kind: ReplicationController
metadata:
  name: tectonic-manager
  namespace: tectonic-system
spec:
  replicas: 1
  selector:
    tectonic-app: manager
  template:
    metadata:
      labels:
        tectonic-app: manager
    spec:
      containers:
      - command:
        - /tectonic-manager
        #image: quay.io/tectonic/manager:v0.4.1
        image: shenshouer/manager:v0.4.1
        name: tectonic-manager
        volumeMounts:
        - mountPath: /etc/tectonic-license/
          name: tectonic-license
      volumes:
      - secret:
          secretName: tectonic-license
        name: tectonic-license
  1. 提交配置文件至集群中
$ kubectl create -f ns-tectonic-system.yaml
namespaces/tectonic-system
$ kubectl get namespace
NAME              LABELS    STATUS
default               Active
kube-system           Active
tectonic-system       Active
$ kubectl create -f rc-tectonic.yml
replicationcontrollers/tectonic-manager

当执行上传操作之后,发现情况不是怎么理想:

sope:wk goyoo$ kubectl get po -o wide --namespace=tectonic-system
NAME                     READY     STATUS                                                             RESTARTS   AGE       NODE
tectonic-manager-o26wr   0/1       Image: shenshouer/manager:v0.4.1 is ready, container is creating   0          1m        172.17.4.201
sope:wk goyoo$

发现镜像已经拉下来了,但始终没有启动。
在git下载的工作目录中使用vagrant ssh w1登陆到从节点上查看kuberlet日志信息:

core@w1 /etc/systemd/system $ journalctl -fu kubelet.service
-- Logs begin at Wed 2015-09-23 07:32:19 UTC. --
Sep 23 11:04:15 w1 kubelet[1227]: E0923 11:04:15.953220    1227 pod_workers.go:111] Error syncing pod c283b0ee-61e2-11e5-a0e9-080027df9088, skipping: secrets "tectonic-license" not found
Sep 23 11:04:25 w1 kubelet[1227]: E0923 11:04:25.938468    1227 secret.go:127] Couldn't get secret tectonic-system/tectonic-license
Sep 23 11:04:25 w1 kubelet[1227]: E0923 11:04:25.938468    1227 kubelet.go:1190] Unable to mount volumes for pod "tectonic-manager-1s3g1_tectonic-system": secrets "tectonic-license" not found; skipping pod
Sep 23 11:04:25 w1 kubelet[1227]: E0923 11:04:25.955782    1227 pod_workers.go:111] Error syncing pod c283b0ee-61e2-11e5-a0e9-080027df9088, skipping: secrets "tectonic-license" not found
Sep 23 11:04:35 w1 kubelet[1227]: E0923 11:04:35.968190    1227 secret.go:127] Couldn't get secret tectonic-system/tectonic-license
Sep 23 11:04:35 w1 kubelet[1227]: E0923 11:04:35.969397    1227 kubelet.go:1190] Unable to mount volumes for pod "tectonic-manager-1s3g1_tectonic-system": secrets "tectonic-license" not found; skipping pod
Sep 23 11:04:35 w1 kubelet[1227]: E0923 11:04:35.972750    1227 pod_workers.go:111] Error syncing pod c283b0ee-61e2-11e5-a0e9-080027df9088, skipping: secrets "tectonic-license" not found
Sep 23 11:04:45 w1 kubelet[1227]: E0923 11:04:45.973012    1227 secret.go:127] Couldn't get secret tectonic-system/tectonic-license
Sep 23 11:04:45 w1 kubelet[1227]: E0923 11:04:45.975243    1227 kubelet.go:1190] Unable to mount volumes for pod "tectonic-manager-1s3g1_tectonic-system": secrets "tectonic-license" not found; skipping pod
Sep 23 11:04:45 w1 kubelet[1227]: E0923 11:04:45.990232    1227 pod_workers.go:111] Error syncing pod c283b0ee-61e2-11e5-a0e9-080027df9088, skipping: secrets "tectonic-license" not found
Sep 23 11:04:55 w1 kubelet[1227]: E0923 11:04:55.974708    1227 secret.go:127] Couldn't get secret tectonic-system/tectonic-license
Sep 23 11:04:55 w1 kubelet[1227]: E0923 11:04:55.975346    1227 kubelet.go:1190] Unable to mount volumes for pod "tectonic-manager-1s3g1_tectonic-system": secrets "tectonic-license" not found; skipping pod
Sep 23 11:04:55 w1 kubelet[1227]: E0923 11:04:55.988686    1227 pod_workers.go:111] Error syncing pod c283b0ee-61e2-11e5-a0e9-080027df9088, skipping: secrets "tectonic-license" not found
Sep 23 11:05:05 w1 kubelet[1227]: E0923 11:05:05.970709    1227 secret.go:127] Couldn't get secret tectonic-system/tectonic-license
Sep 23 11:05:05 w1 kubelet[1227]: E0923 11:05:05.973035    1227 kubelet.go:1190] Unable to mount volumes for pod "tectonic-manager-1s3g1_tectonic-system": secrets "tectonic-license" not found; skipping pod
Sep 23 11:05:05 w1 kubelet[1227]: E0923 11:05:05.990815    1227 pod_workers.go:111] Error syncing pod c283b0ee-61e2-11e5-a0e9-080027df9088, skipping: secrets "tectonic-license" not found

从日志信息中可以看出此时需要tectonic-license。提交注册是下载的tectonic-preview-license.yaml文件到集群,提交之前先删除之前提交的rc.

$ kubectl delete -f rc-tectonic.yaml
replicationcontrollers/tectonic-manager
$ kubectl create -f tectonic-preview-license.yaml
secrets/tectonic-license

secret已经创建成功,后再创建Tectonic Services服务:

$ kubectl get secret --all-namespaces
NAMESPACE         NAME                  TYPE                                  DATA
default           default-token-oqsu6   kubernetes.io/service-account-token   2
kube-system       default-token-sl65x   kubernetes.io/service-account-token   2
tectonic-system   default-token-p9pmu   kubernetes.io/service-account-token   2
$ kubectl create -f rc-tectonic.yaml

安装Tectonic Services需要kubernetes的全部特性,并且会自动在kubernetes集群中安装tectonic-console与tectonic-support的容器服务。这两个容器服务支持也是从coreos的官方镜像仓库下载,速度非常缓慢。

当Tectonic Services启动完成之后会有如下几个服务容器:

sope:wk goyoo$ kubectl get po -o wide --namespace=tectonic-system
NAME                     READY     STATUS    RESTARTS   AGE       NODE
tectonic-console-b2u6o   1/1       Running   2          14h       172.17.4.201
tectonic-manager-oh3pi   1/1       Running   0          14h       172.17.4.201
tectonic-support-w0dia   1/1       Running   0          14h       172.17.4.201

暴露Tectonic Console到浏览器

默认情况下Tectonic Console没有暴露到集群之外,为了达到这个目的需要创建一个kubernetes service来进行。此过程有两个方法:
1. 使用NodePort
2. 使用LoadBalancer

使用NodePort方式

参考模板tectonic-console-public.yml,其内容如下:

apiVersion: v1
kind: Service
metadata:
  name: tectonic-console-public
  namespace: tectonic-system
spec:
  type: NodePort
  ports:
    - port: 80
      nodePort: 32000
      protocol: TCP
      name: tectonic-console-expose
  selector:
    tectonic-app: console
    tectonic-component: ui

创建kubernetes服务:

sope:wk goyoo$ kubectl --namespace=tectonic-system create -f tectonic-console-public.yml
You have exposed your service on an external port on all nodes in your
cluster.  If you want to expose this service to the external internet, you may
need to set up firewall rules for the service port(s) (tcp:32000) to serve traffic.   
See http://releases.k8s.io/HEAD/docs/user-guide/services-firewalls.md for more details.
services/tectonic-console-public

然后就可以通过在浏览器中打开http://[host]:32000访问了,其中host是任何一个在集群中的worker节点,在本例子中只有一个worker节点即w1,其对外ip地址为172.17.4.201

访问效果如下图所示:
这里写图片描述

使用LoadBalancer

参考模板tectonic-console-cloud.yml,其内容如下:

apiVersion: v1
kind: Service
metadata:
  name: tectonic-console-public
  namespace: tectonic-system
spec:
  type: LoadBalancer
  ports:
    - port: 80
      protocol: TCP
      name: tectonic-console-expose
  selector:
    tectonic-app: console
    tectonic-component: ui

注意:如果没有提供云配置资质,此服务可以创建,但 cloud load balancer服务不会创建。在本地虚拟机测试建议使用使用NodePort方式方法。

$ kubectl --namespace=tectonic-system create -f tectonic-console-cloud.yml
services/tectonic-console-cloud
Logo

开源、云原生的融合云平台

更多推荐