Tekton安装镜像

knative自v0.7.0开始废弃现有的build而拥抱tekton,由于均是基于google的项目,所以镜像下载成为一个大问题。本文采用类似于knative墙内安装 的方式来处理镜像和安装脚本,适用于墙内安装体验。

安装流程

主要是替换yaml中无法墙内无法拉取到的gcr镜像的流程,具体如下。

生成所需yaml

下面是下载tekton安装yaml文件,并替换其中的gcr.io的镜像为ljchen提供的镜像的脚本。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
TEKTON_PATH='tekton'
TEKTON_VER='v0.4.0'
REGISTRY_URL='ljchen'

rm -rf $TEKTON_PATH
mkdir $TEKTON_PATH


# download yaml
echo "download yaml files ..."

cd $TEKTON_PATH

wget -q https://storage.googleapis.com/tekton-releases/latest/release.yaml

cd ..

# get images list
echo "collect image to tmp file ..."

cd $TEKTON_PATH
rm -rf image.tmp

for line in `grep -RI " image: " *.yaml | grep gcr.io`
do
if [[ ${line} =~ 'gcr.io' ]]
then
if [[ ${line} =~ 'gcr.io/tekton-releases/github.com/tektoncd' ]]
then
sub_line1=${line##gcr.io/tekton-releases/github.com/tektoncd/}
sub_line2=${sub_line1%%@sha*}
container_name=tekton_${sub_line2//\//_}

echo ${line#image:} ${REGISTRY_URL}/${container_name}:${TEKTON_VER} >> image.tmp
else
sub_line1=${line#image:}
sub_line2=${sub_line1#*/}
sub_line3=${sub_line2%%:*}
container_name=tekton_${sub_line3//\//_}

echo ${line#image:} ${REGISTRY_URL}/${container_name}:${TEKTON_VER} >> image.tmp;
fi
fi
done

for line in `grep -RI " - " *.yaml | grep gcr.io`
do
if [[ ${line} =~ 'gcr.io' ]]
then
if [[ ${line} =~ 'gcr.io/tekton-releases/github.com/tektoncd' ]]
then
sub_line1=${line##gcr.io/tekton-releases/github.com/tektoncd/}
sub_line2=${sub_line1%%@sha*}
container_name=tekton_${sub_line2//\//_}

echo ${line#value:} ${REGISTRY_URL}/${container_name}:${TEKTON_VER} >> image.tmp
else
sub_line1=${line#value:}
sub_line2=${sub_line1#*/}
sub_line3=${sub_line2%%:*}
container_name=tekton_${sub_line3//\//_}

echo ${line#value:} ${REGISTRY_URL}/${container_name}:${TEKTON_VER} >> image.tmp;
fi
fi
done


cd ..


# replace file image

cd $TEKTON_PATH

counter=0
for file in *.yaml
do
echo "开始处理文件 " $file

while read line
do
origin_image=`echo ${line} | awk '{print $1}'`
new_image=`echo ${line} | awk '{print $2}'`

tmp=${origin_image//\//__}
origin_image=${tmp//__/\\/}

tmp2=${new_image//\//__}
new_image=${tmp2//__/\\/}

sed -i "s/${origin_image}/${new_image}/g" ${file}
#上面这行,如果是MacOS/UNIX请替换为: sed -i " " "s/${origin_image}/${new_image}/g" ${file}

done < image.tmp
counter=`expr ${counter} + 1`
done

echo "共处理文件数:" ${counter}

rm -rf *.yaml.1
cd ..

# finish
echo "completed..."

部署

执行完脚本之后,会生成对应的文件目录如下图所示:

1
2
3
4
5
6
~/Desktop/tekton  tree
.
├── install.sh
├── tekton
   ├── image.tmp
   └── release.yaml

其中的release.yaml文件就是我们所需的安装文件,直接kubectl apply -f release.yaml即可安装。安装完后,在tekton-pipelines命名空间下,会生成对应的pod,看名称和knative的build很像。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 查看pod,同build一致,均包含controller和webhook
~/Desktop/tekton  kct get pod
NAME READY STATUS RESTARTS AGE
tekton-pipelines-controller-6cf456fc89-sfjzs 1/1 Running 0 30m
tekton-pipelines-webhook-58c9896d9b-6qd7v 1/1 Running 0 30m

# 对应的CRD列表,看到资源名称不同于原有build中的build和build-template
~/Desktop/tekton  kct get crd | grep tekton
clustertasks.tekton.dev 2019-06-29T12:44:38Z
pipelineresources.tekton.dev 2019-06-29T12:44:38Z
pipelineruns.tekton.dev 2019-06-29T12:44:38Z
pipelines.tekton.dev 2019-06-29T12:44:38Z
taskruns.tekton.dev 2019-06-29T12:44:38Z
tasks.tekton.dev 2019-06-29T12:44:38Z

安装dashboard

  1. 下载dashboard的yaml文件:

    1
    wget https://raw.githubusercontent.com/tektoncd/dashboard/master/config/release/gcr-tekton-dashboard.yaml
  2. 替换gcr-tekton-dashboard.yaml 中的镜像 gcr.io/tekton-nightly/dashboard:latestljchen/tekton-nightly_dashboard:latest;

  3. 部署到k8s,并映射端口出来。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    ~  kct get pod
    NAME READY STATUS RESTARTS AGE
    tekton-dashboard-9bddff6bb-rzj6d 1/1 Running 0 6m43s
    tekton-pipelines-controller-6cf456fc89-sfjzs 1/1 Running 1 12h
    tekton-pipelines-webhook-58c9896d9b-6qd7v 1/1 Running 1 12h

    ~  kct get svc
    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    tekton-dashboard ClusterIP 10.99.93.239 <none> 9097/TCP 6m45s
    tekton-pipelines-controller ClusterIP 10.100.85.20 <none> 9090/TCP 12h
    tekton-pipelines-webhook ClusterIP 10.97.218.191 <none> 443/TCP 12h

    ~  kct port-forward --address 0.0.0.0 pod/tekton-dashboard-9bddff6bb-rzj6d 8888:9097
    Forwarding from 0.0.0.0:8888 -> 9097

以下是打开后的界面,主要从tekton抽象概念的视角分别展现内容。另外,还提供了对resources引入的快捷操作。

配套镜像生成脚本

正常情况下,你不需要关注该脚本,除非己希望在墙外生成镜像并推送到自己的镜像仓库。对于只希望安装tokton的读者,请直接使用上一步中的yaml文件部署。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
TEKTON_PATH='tekton'
TEKTON_VER='v0.4.0'
REGISTRY_URL='ljchen'

rm -rf $TEKTON_PATH
mkdir $TEKTON_PATH


# download yaml

echo "download yaml files ..."

cd $TEKTON_PATH

wget -q https://storage.googleapis.com/tekton-releases/latest/release.yaml

cd ..


# get images list

echo "collect image to tmp file ..."

cd $TEKTON_PATH
rm -rf image.tmp

for line in `grep -RI " image: " *.yaml | grep gcr.io`
do
if [[ ${line} =~ 'gcr.io' ]]
then
if [[ ${line} =~ 'gcr.io/tekton-releases/github.com/tektoncd' ]]
then
sub_line1=${line##gcr.io/tekton-releases/github.com/tektoncd/}
sub_line2=${sub_line1%%@sha*}
container_name=tekton_${sub_line2//\//_}

echo ${line#image:} ${REGISTRY_URL}/${container_name}:${TEKTON_VER} >> image.tmp
else
sub_line1=${line#image:}
sub_line2=${sub_line1#*/}
sub_line3=${sub_line2%%:*}
container_name=tekton_${sub_line3//\//_}

echo ${line#image:} ${REGISTRY_URL}/${container_name}:${TEKTON_VER} >> image.tmp;
fi
fi
done

for line in `grep -RI " - " *.yaml | grep gcr.io`
do
if [[ ${line} =~ 'gcr.io' ]]
then
if [[ ${line} =~ 'gcr.io/tekton-releases/github.com/tektoncd' ]]
then
sub_line1=${line##gcr.io/tekton-releases/github.com/tektoncd/}
sub_line2=${sub_line1%%@sha*}
container_name=tekton_${sub_line2//\//_}

echo ${line#value:} ${REGISTRY_URL}/${container_name}:${TEKTON_VER} >> image.tmp
else
sub_line1=${line#value:}
sub_line2=${sub_line1#*/}
sub_line3=${sub_line2%%:*}
container_name=tekton_${sub_line3//\//_}

echo ${line#value:} ${REGISTRY_URL}/${container_name}:${TEKTON_VER} >> image.tmp;
fi
fi
done

cd ..


download image, tag, push

cd $TEKTON_PATH

while read line
do
origin_image=`echo ${line} | awk '{print $1}'`
new_image=`echo ${line} | awk '{print $2}'`

echo "old:" ${origin_image}
echo "new:" ${new_image}
docker pull ${origin_image}
docker tag ${origin_image} ${new_image}
docker push ${new_image}

done < image.tmp

cd ..

# done

echo "completed..."

gcr镜像映射表

老问题,排版有点儿难看,见谅!

  1. gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller@sha256:80e040a58ce6c4d58ae893eb934777bce013ef8be079967dc3db783d76fa5aaa
    => ljchen/tekton_pipeline_cmd_controller:v0.4.0

  2. gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/webhook@sha256:da75fbdaeb800813d85b99f7f54b665e8d0edbb2c5a7ffc6a99d66aede0291a3
    => ljchen/tekton_pipeline_cmd_webhook:v0.4.0

  3. gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/kubeconfigwriter@sha256:2000fdb77fd830719533756afe246c460949b46eb0c7fc1841de17656d6f5114
    => ljchen/tekton_pipeline_cmd_kubeconfigwriter:v0.4.0

  4. gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/creds-init@sha256:b4877c99d928fad3cf26c995d171674b34d206178d6f9f0efb337ebff01bb34b
    => ljchen/tekton_pipeline_cmd_creds-init:v0.4.0

  5. gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init@sha256:4b91c31560f18a8f09c68d5288f2261797b6df31522a57a9d7350bc0060a1284
    => ljchen/tekton_pipeline_cmd_git-init:v0.4.0

  6. gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/nop@sha256:9160ed41b20b2822d06e907d89f6398ea866c86a971f83371efb9e147fba079f
    => ljchen/tekton_pipeline_cmd_nop:v0.4.0

  7. gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/bash@sha256:0355a9b21a7c0cc9466bf75071648e266de07b5e13fbfd271ec791c45a818bdb
    => ljchen/tekton_pipeline_cmd_bash:v0.4.0

  8. gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/gsutil@sha256:6b6b8e02f6f03fb33cf3007b6b501e07bf2f435a0309482b868712a20f1dfd78
    => ljchen/tekton_pipeline_cmd_gsutil:v0.4.0

  9. gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/entrypoint@sha256:4d1fe990ca06ecc671370dfeab31d857efa8ccf81d632a672561c60482fd9aae
    => ljchen/tekton_pipeline_cmd_entrypoint:v0.4.0

  10. gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/imagedigestexporter@sha256:3d36cb375da0e4b5b5cf8b0964ed3d80f4645142ac609679c3b26a369f3ed340
    => ljchen/tekton_pipeline_cmd_imagedigestexporter:v0.4.0

  11. gcr.io/tekton-nightly/dashboard:latest
    => ljchen/tekton-nightly_dashboard:latest (该镜像构建时间为2019-06-30)

0%