Hello

Filipe Pinheiro

@fampinheiro

Software Enginner @ YLD

Node.js

From code to

Production

Disclaimer

Docker ✋

Development Process

Development Process

Gitlab ✋

Gitlab

Continuous Integration ✋

Gitlab

Continuous Integration

Gitlab

Runners

Gitlab

Runner + docker

$ export GL_RUNNER_NAME=gitlab-runner
$ docker run -d --name $GL_RUNNER_NAME --restart=on-failure \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /var/lib/gitlab-runner/$GL_RUNNER_NAME/config:/etc/gitlab-runner \
  gitlab/gitlab-runner:latest
$ export CI_GITLAB_URL= # https://gitlab.com/ci
$ export CI_RUNNER_TOKEN= # "settings > ci/cd pipelines"
$ docker exec -it $GL_RUNNER_NAME gitlab-runner register -n \
  --url $CI_GITLAB_URL --tag-list "docker" \
  --registration-token $CI_RUNNER_TOKEN \
  --executor docker --description "docker runner" \
  --docker-image "docker:latest" --docker-privileged \
  --docker-volumes "/var/run/docker.sock:/var/run/docker.sock"

Gitlab

Test

.gitlab-ci.yml

test:dev:
  script:
  - docker build -t $GL_IMAGE_NAME:$GL_IMAGE_TAG .
  - docker run $GL_IMAGE_NAME:$GL_IMAGE_TAG npm run test
  stage: test

Gitlab

Continuous Integration 🙌

Gitlab

Continuous Delivery ✋

Gitlab

Continuous Delivery

Gitlab

Build

.gitlab-ci.yml

build:
  script:
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $REGISTRY
  - docker build -t $GL_IMAGE_NAME:$GL_IMAGE_TAG .
  - docker push $GL_IMAGE_NAME:$GL_IMAGE_TAG
  stage: build

Gitlab

Continuous Delivery 🙌

Kubernetes ✋

kubernetes logo

Kubernetes

Objects

Deployment

Services

Secrets

Job

...

Kubernetes

Configuration

apiVersion: v1
kind: Pod
metadata:
  ...
spec:
  containers:
  - name: hello
    image: registry.gitlab.com/fampinheiro/hello:1dcc0c
    ...

Kubernetes

kubectl

$ kubectl create <options> [--save-config]
$ kubectl apply <options>
$ kubectl delete <options>

Gitlab

+

Kubernetes

Gitlab + Kubernetes

Continuous Deployment ✋

Gitlab + Kubernetes

Continuous Deployment

Gitlab

Deploy

.gitlab-ci.yml

deploy:
  script:
  - docker build -t $CI_JOB_ID -f bin/dockerfile.deploy .
  - docker run
    --env KUBE_KEY_FILE="$KEY_FILE"
    ...
    $CI_JOB_ID
  stage: deploy
  tags:
  - docker

Gitlab + Kubernetes

Configuration

...
spec:
  ...
  imagePullSecrets:
  - name: gitlab-registry
$ kubectl create secret docker-registry gitlab-registry \
  --docker-username='' --docker-password='' \
  --docker-email='' --docker-server=''

Kubernetes

Gitlab + Kubernetes

Continuous Deployment 🙌

Gitlab

Pipeline

Demo

Trust

Trust

Logging

Monitoring

Security

Storage

Testing

...

Bye

filipe@yld.io