k8s-cronjob

当前k8s版本:1.17,在使用cronjob的时候发现调度的时间不对,配置的是0 0 * * *,但实际运行时间为早上8点,推测是时区问题没跑了~ 但是运行程序的容器已经处理过时区问题,而且调度是k8s发起了,问题在k8s那边。

[阅读全文]
k8s  cronjob 

golang私有仓库

https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more

https://golang.org/ref/mod#private-modules

https://golang.org/ref/mod#vcs-find

https://golang.org/doc/tutorial/create-module

https://sagikazarmark.hu/blog/vanity-import-paths-in-go/

https://medium.com/@dayakar88/a-guide-to-solve-no-go-import-meta-tags-for-private-repositories-with-go-modules-6b9237f9c9f

为了gitlab-ci在构建时拉取私有仓库依赖,构建工作使用的docker容器的dockerfile需要加上:

1
2
3
4
RUN git config --global url."git@192.168.1.10:".insteadOf "https://192.168.1.10/"
COPY gitlab-ci /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa
RUN echo "    StrictHostKeyChecking no" >> /etc/ssh/ssh_config

其中的id_rsa为部署密钥,需要在私有仓库中添加部署密钥 上述参考 https://cloud.tencent.com/developer/article/1602151 https://stackoverflow.com/questions/27500861/whats-the-proper-way-to-go-get-a-private-repository

[阅读全文]

sonarqube+gitlab

目标

安装SonarQube,在gitlab-runner上运行SonarScanner,SonarQube与Gitlab的账户打通

安装SonarQube

很简单,参考官方文档即可

[阅读全文]

git常用操作指南

创建分支git branch <name>,创建叫name的分支,但仍然停留在当前分支。

删除分支git branch -d <name>,参数为-D则为强制删除。

[阅读全文]
git 

golang plugin从入门到放弃

最开始看到go plugin很兴奋,太实用了。正好手上项目也能用得上,所以花了几天心思去研究一下,所以就有了这篇文章的心德:go plugin从入门到放弃

[阅读全文]

golang learning 2

数据类型

int/uint类型位数不是固定的,根据运行平台可能是32位或64位 获取Int类型位数:strconv.IntSize

Go不允许隐式类型转换,只能强制转换 强制转换:int32(a)

[阅读全文]

brew 切换源

切换到国内源

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 替换brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# 刷新
brew update

切换到官方源

[阅读全文]
macOS  brew 

golang开发windows应用添加图标

开源工具源码地址:github.com/akavel/rsrc

  • 下载rsrc工具
  • 创建一个manifest文件
1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="Amd64" name="controls" type="win32"></assemblyIdentity>
<dependency>
    <dependentAssembly>
        <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="Amd64" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
    </dependentAssembly>
</dependency>
</assembly>
  • windows下生成syso文件
1
rsrc_windows_amd64.exe -manifest manifest -ico inventory.ico -arch amd64 -o inventory.syso
  • 构建
1
GOOS=windows CGO_ENABLED=1 GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -ldflags '-w -s' .

注意,网上找到的资料都会报以下的错:

[阅读全文]

使用gitlab + gitlab runner + nexus + k8s技术栈搭建devops全流程

版本清单

  • gitlab:12.8.1-ce.0
  • gitlab runner:v12.9.0
  • nexus:3.21.1
  • k8s:1.17.4
  • istio:1.5.1

前提条件

  • maven镜像未使用官方的,而是基于JDK镜像自己创建,原因是官方的镜像对于配置全局mirror没有找到简单方便的办法
  • kubectl官方没有镜像,当前使用的是:bitnami/kubectl

安装过程

gitlab

  • 使用compose安装:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  gitlab:
    image: gitlab/gitlab-ce:12.8.1-ce.0
    ports:
    - '22:22'
    - '80:80'
    - '443:443'
    volumes:
    - /data/gitlab/config:/etc/gitlab
    - /data/gitlab/logs:/var/log/gitlab
    - /data/gitlab/data:/var/opt/gitlab
    container_name: gitlab
    restart: unless-stopped
  • gitlab.rb配置文件修改:
 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
external_url 'https://ip'

gitlab_rails['time_zone'] = 'Asia/Shanghai'

gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'xxx@xxx.xxx'
gitlab_rails['gitlab_email_display_name'] = 'xxx'

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.xxx.xxx.xxx"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxx@xxx.xxx"
gitlab_rails['smtp_password'] = "********"
gitlab_rails['smtp_domain'] = "xxx.xxx"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

user['git_user_name'] = "GitLab"
user['git_user_email'] = "xxx@xxx.xxx"

nginx['enable'] = true
nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80

nginx['ssl_certificate'] = "/etc/gitlab/trusted-certs/xxx.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/trusted-certs/xxx.key"

mysql federated引擎使用

跨服务器操作mysql数据库的需求,mysql提供了federated引擎,进行表映射,然后进行操作

步骤:

  1. 确认federated引擎是否启用,执行:show engines查看引擎状态,找到federated的Support,默认是关闭的,即NO

    [阅读全文]