2024年 09月 10日 - 在k8s中安装Gitlab runner

    添加helm仓库

    helm repo add gitlab https://charts.gitlab.io
    helm search repo gitlab/gitlab-runner --version 0.42.0
    

    生成values.yaml文件

    helm show values gitlab/gitlab-runner --version 0.42.0 > values.yaml
    

    修改自定义的values.yaml文件内容

    gitlabUrl: 'https://gitlab.xxxx.com/'
    runnerRegistrationToken: 'xxxxx'
    unregisterRunners: true
    concurrent: 2
    checkInterval: 5
    
    
    image:
      registry: registry.gitlab.com
      image: gitlab-org/gitlab-runner
      tag: alpine-v15.1.0
    
    rbac:
      create: true
      rules:
        - apiGroups: [ '' ] #"" indicates the core API group
          resources: [ '*' ]
          verbs: [ '*' ]
        - apiGroups: [ 'networking.k8s.io' ]
          resources: [ 'ingresses' ]
          verbs: [ '*' ]
        - apiGroups: [ 'apps' ]
          resources: [ 'deployments' ]
          verbs: [ '*' ]
      clusterWideAccess: true
      serviceAccountName: gitlab-runner
    
    runners:
      config: |
        [[runners]]
          [runners.kubernetes]
            namespace = ""
            image = "ubuntu:18.04"
          [runners.cache]
            Type = "s3"
            Shared = false
            [runners.cache.s3]
              ServerAddress = "minio.xxx.com"
              # AccessKey = "${S3_ACCESS_KEY}"  # 使用环境变量存储密钥
              # SecretKey = "${S3_SECRET_KEY}"  # 使用环境变量存储密钥
              AccessKey = "xxxx"
              SecretKey = "xxxx"
              BucketName = "gitlab-cache"
              # 如果可能,尽量启用 HTTPS
              Insecure = true
      tags: 'k8s-runner'
      helpers:
        cpuLimit: 200m
        memoryLimit: 256Mi
        cpuRequests: 100m
        memoryRequests: 128Mi
        image: 'registry.gitlab.com/gitlab-runner-helper:arm64-76984217'
      serviceAccountName: gitlab-runner
    
    

    查看模板与自定义配置生成的内容(可选)

    
    # helm template -f values.yaml --namespace gitlab-runner gitlab/gitlab-runner > gitlab-runner.yaml
    
    

    安装或更新

    helm install -f ./values.yaml gitlab-runner gitlab/gitlab-runner -n gitlab-runner --version 0.42.0
    
    helm upgrade -f ./values.yaml gitlab-runner gitlab/gitlab-runner -n gitlab-runner --version 0.42.0
    

    查看部署状态

    helm status gitlab-runner -n gitlab-runner
    

    卸载

    helm delete gitlab-runner -n gitlab-runner
    

    2024年 08月 17日 - 使用acme.sh生成letsencrypt的泛域名证书

    使用acme.sh生成letsencrypt的泛域名证书

    • 原先的服务器都是使用的certbot,没有使用泛域名证书,每次新增一个服务需要手动执行一次
    • Challenge Types有多种模式,其中DNS支持泛域名证书,早期列出的DNS域名服务商没有阿里云
      • HTTP-01 challenge
      • DNS-01 challenge
      • TLS-SNI-01
      • TLS-ALPN-01

    acme.sh支持通过阿里云的API实现的

    域名服务商支持列表

    DNS Hosting Provider ACME Client Support Cost
    Akamai Edge DNS 443 Certbot 339, lego 3.0k, Posh-ACME 3.0k , acme.sh 16.0k Contract Specific
    Aliyun (CN) 251 & Alibaba Cloud DNS (EN) 127 acme.sh 16.0k, lego 3.0k, Posh-ACME 3.0k Bundled with domain registration or Cloud DNS pricing 132
    Amazon Route53 Certbot 1.8k, acme.sh 16.0k, others 2.3k ~$0.50/mo per domain
    Azure DNS acme.sh 16.0k, lego 3.0k, Posh-ACME 3.0k ~$0.50/mo per domain
    Cloudflare Certbot 3.4k, acme.sh 16.0k, others 2.3k Free (except for Freenom domains) 3.1k Note: Cloudflare is also a Registrar.
    ClouDNS acme.sh 16.0k, lego 3.0k, Posh-ACME 3.0k, others 2.3k >= $2.95/mo (with API-support)

    docker方式运行

    阿里云access_key申请

    --dns dns_ali表示域名服务商名称为ali

    docker run --rm -it -v "$(pwd)/out":/acme.sh \
      -e Ali_Key=your_access_key_id \
      -e Ali_Secret=your_access_key_secret \ 
      neilpang/acme.sh --issue --dns dns_ali --server letsencrypt \
      -d *.eoekun.top --dnssleep 300
    

    2024年 07月 19日 - gitlab多项目cicd构建方案

    gitlab多项目cicd构建方案

    解决: 多应用构建场景、依赖服务构建场景

    基于docker run -it --rm -p 4000:4000 registry.gitlab.com/gitlab-org/gitlab-docs:13.11

    Moved to GitLab Free in 12.8.

    http://0.0.0.0:4000/13.11/ee/ci/multi_project_pipelines.html

    官方文档

    好文

    2024年 06月 27日 - java中的webp图像处理

    java中使用thumbnailator实现图片压缩

    public static void main(String args[]) throws IOException {
      // 原始比例大小,0.5倍清晰度
      Thumbnails.of(new File("original.jpg")).scale(1f).outputQuality(0.5f).toFile(new File("thumbnail.jpg"));
    }