[OK!] Chapter 12. Preparing for a New Pipeline


Делаю:
31.08.2023


Ничего интересного. Здесь просто запускаем приложение без использования Tekton. Просто собираем в контейнере и запускаем в kubernetes.


Поднимаем новый minikube


Настраиваем для работы.


$ kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
$ kubectl apply -f https://storage.googleapis.com/tekton-releases/triggers/latest/release.yaml
$ kubectl apply -f https://storage.googleapis.com/tekton-releases/triggers/latest/interceptors.yaml
$ kubectl apply -f https://raw.githubusercontent.com/tektoncd/triggers/main/examples/rbac.yaml


Finally, you need to make one last adjustment to your cluster to be able to deploy your applications automatically. You will need to give the appropriate role to your service account so that it can access the Kubernetes API and automatically update your application. You can use the following command to do so:


$ kubectl create clusterrolebinding \
  serviceaccounts-cluster-admin \
  --clusterrole=cluster-admin \
  --group=system:serviceaccounts


$ tkn version
Client version: 0.31.0
Pipeline version: v0.50.0
Triggers version: v0.24.1


Exploring the source code


https://github.com/PacktPublishing/tekton-book-app


Форкаем


$ cd ~/tmp/
$ git clone https://github.com/<YOUR_USERNAME>/tekton-book-app


$ cd tekton-book-app


$ npm install
$ npm start


$ curl localhost:3000
$ curl localhost:3000/add/12/10
$ curl localhost:3000/substract/10/2


$ cd ~/tmp/tekton-book-app/
$ npm run lint
$ npm run test


Building and deploying the application


$ export DOCKER_USERNAME=<YOUR_USERNAME>
$ docker build -t ${DOCKER_USERNAME}/tekton-lab-app .
$ docker login docker.io
$ docker push ${DOCKER_USERNAME}/tekton-lab-app


Deploying the application


**Не забыть заменить на свой.**


$ cat << 'EOF' | envsubst | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tekton-deployment
spec:
  selector:
    matchLabels:
      app: trigger-demo
  template:
    metadata:
      labels:
        app: trigger-demo
    spec:
      containers:
      - name: tekton-pod
        image: ${DOCKER_USERNAME}/tekton-lab-app
        ports:
        - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: tekton-svc
spec:
  selector:
    app: trigger-demo
  ports:
  - port: 3000
    protocol: TCP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: tekton-ingress
spec:
  rules:
  - http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: tekton-svc
            port:
              number: 3000
EOF


$ kubectl get pods
NAME                                 READY   STATUS    RESTARTS   AGE
tekton-deployment-5d5d5fd747-9dcn4   1/1     Running   0          78s


// Убеждаемся, что значение профиля установлено
$ echo ${PROFILE}


$ curl $(minikube --profile ${PROFILE} ip)
{"message":"Hello","change":"что-то"}


OK!


Далее нудная процедура по изменению кода и обновлению всего и вся, чтобы показать нам как все это нудно делать руками.