Category - SCM-tool

2021-08-02 09:33:26    857    0    0

repo

常用命令

同步代码

  1. repo sync -j8

打tag

  1. ## # 对所有project 的当前分支的最新代码打一个tag
  2. repo start ${Base_BRANCH} --all
  3. repo forall c git tag base-20210803

合并分支

  1. ## # 当前切换到master 分支 ,然后将topic 分支合并到master
  2. ## repo checkout master
  3. ## repo forall –p –c git merge topic
  4. ## repo forall –c git tag base-20210804
  5. ## repo forall –p –c git merge branch1

查看分支

  1. repo branches

查看状态

  1. repo status

分支log 比较

  1. repo forall -p -c 'git log remotes/xxx-celadon/celadon-1 ^remotes/xxx-celadon/celadon-2 --pretty=format:"%H %cn %s"'
? gitlab ?    2021-01-06 15:19:23    1055    0    0
  1. gitlab web : User Setting --> Access Tokens

API_VERSION:

  1. https://gitlab.casa-systems.com/help/api/v3_to_v4.md
  2. In GitLab 9.0 and later, API V4 is the preferred version to be used.

jq command:

  1. https://stedolan.github.io/jq/manual/#Invokingjq



gitlab api 根据指定组名取组对象

  1. curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq .

gitlab api 根据指定组名取组里的元素属性

  1. curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq 'keys'

gitlab api 根据指定组名取组里的第一个project里的属性

  1. curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName} 2>/dev/null|jq .projects[0]|jq 'keys'

gitlab api 根据指定组名取组的任一key的值

  1. curl --header "PRIVATE-TOKEN: $P_token" $GITLAB_INSTANCE/api/$API_VERSION/groups/${GroupName
2020-11-23 14:23:08    750    0    0

工具 winscp

windows 7 , WinSCP-5.9.3-Portable

  1. winscp> help
  2. call Executes arbitrary remote command
  3. cd Changes remote working directory
  4. checksum Calculates checksum of remote file
  5. chmod Changes permissions of remote file
  6. close Closes session
  7. echo Displays its arguments as message
  8. exit Closes all sessions and terminates the program
  9. get Downloads file from remote directory to local directory
  10. help Displays help
  11. keepuptodate Continuously reflects changes in local directory on remote one
  12. lcd Changes local working directory
  13. lls Lists the contents of local directory
  14. ln Creates remote symbolic link
  15. lpwd Prints local working directory
  16. ls Lists the contents of remote directory
  17. mkdir Creates remote directory
  18. mv Moves or renames remote file
  19. open Connects to server
  20. option Sets or shows value of script options
  21. put Uploads file
2020-06-10 10:57:10    786    0    0

平时的配置管理概念默认是指都是指源代码的版本管理,这一章整理一些系统环境的配置管理

整理中。。。。。

saltstack

https://docs.saltstack.com/en/latest/

SaltStack是一种革命性的基础设施管理方法,它以速度取代了复杂性。SaltStack非常简单,可以在几分钟内运行,可扩展程度足以管理数万台服务器,速度足以在几秒钟内与每个系统通信。

Salt Master

Salt Master 上安装了中心管理系统,配置和指令是由master 发往minions 的

Salt minion

Salt minion 被管理系统上安装着Salt minion ,由Salt minion 接收来自master 的指令

Execution Modules 执行模块

从命令行对一个或多个受管理系统执行的临时命令。适用于:

  1. 实时监控、状态和库存
  2. 一次性命令和脚本
  3. 部署关键更新
Formulas (States)

系统配置的声明式或命令式表示。

Grains(系统变量)

(系统变量)。粒度是关于底层托管系统的静态信息,包括操作系统、内存和许多其他系统属性。还可以为任何系统定义自定义粒度。

Pillar (用户定义的变量)

用户定义的变量。这些安全变量被定义并存储在Salt主服务器上,然后使用目标将其“分配”给一个或多个“仆从”。Salt pillar数据存储端口、文件路径、配置参数和密码等值。

Top File

将Formulas和Pillar数据与minion进行匹配

Runner

在Salt Master上执行支持任务的模块。Salt runner报告作业状态、连接状态、从外部api读取数据、查询连接的Salt minions等等。
例如,Orchestrate runner协调跨许多系统的配置部署

Returnne
? accurev ?    2020-06-08 14:03:25    675    0    0

Accurev workspace 有一个include/exclude 功能,可以在workspace 中增加规则,使workspace 只看到,只更新想关注的列表。
对于被排除在外的元素,不可见,不更新,不会提交,不影响


title

workspace Exploer

切换到workspace exploer
title

Include/Exclude View

在workspace 左侧导栏 下方,勾选 include/exclude view 右击文件视图上方会出现 include.exclude 功能的按扭
title

根据需要设置需要的视图效果

Include : 包含在视图
Include Directry Only : 只包含目录,不包含目录下的文件
Exclude : 排除在外
一个元素上只能有一种规则
顶部元素没有设置rule的,按默认显示

设置之后右侧视图上方展示workspace 的元素,下方展示元素上被设置的规则


例子

/gua/gua2/test1.txt
/hua/hua2/test2.txt
/hua/hua2/test1.txt
/dua/dua2/test/test3.txt

设置一个workspace ,使之更新时将/dua目录及目录下的文件排除在外,即workspace视图 对stream 的dua 目录不可见

  1. /dua :exclude

设置一个workspace ,使之更新时只会更新到/hua/hua2/test2.txt,对此文件外的其他文件及目录不可见。

  1. /dua :exclude
  2. /gua :exclude
  3. /hua :include directory only
  4. /hua/hua2 :include directory only
  5. /hua/hua2/test2.txt :include

Accurev 其他相关笔记
安装时报错:
http://blog.leanote.com/post/gua_l

? accurev ?    2020-05-15 15:11:26    564    1    0

Accurev GUI 里新建 stream 的界面有三个元素:

Stream Name: 自定义名称
Basis: 爸爸stream
Stream Type : stream 类型
Base Time : 基准时间


GUI 创建入口

新建 :Base stream 上右击菜单,new stream
修改 :在建成的stream 上右击菜单是,change stream
一般情况下我们新建的都是 Dynamic Stream ,图标是波浪线或时钟。


类型和时间

title


Dynamic Stream : 类型

这种类型的stream 的图标有两种,一种是三条波浪线,一种是时钟
两种情况可以互相转换,通过把basetime 从None 和 其他三种时间的切换实现

波浪线 :(none)

title
波浪线表示可以本流是实时同步父流同步的提交的,实时接收父流的修改,即两流从上而下的关系是畅通的意思, New stream 的页面,Based time里选 None , 即上下游之间无关时间闸门阻隔。

时钟 : ( now / transaction / special time )

title
时钟表示这个动态流上打上了一个时间闸门,即以basetime 里设置的时间作为一个时间节点,这个时间节点以后,在父流提交的东西,不会往下流到本流。
New stream 的页面,Based time 的 Now , Transaction # , specail time 三个选项都可以设置时间闸门。

now

会以创建时间为准,保存时,将当前时间转换成一个具体的时间戳。创建成功后再查看时间,是当时的now. 不同时间点now 都有不同含义。常用于需要最新修改,但是不要以后的修改流下来的情况

As transaction

在base stream 的history 里,每一条promote 都有一个对应的transaction ID , 这背后也是对应着的一个时间戳,可以在该base time 的histroy 里选一条提交的transaction ID ,或者选全局的一个trans

? k8s ?    2020-04-14 10:54:42    893    0    0


fluxCD

https://fluxcd.io/
The GitOps operator for Kubernetes


填补了构建和监控之间的空白 ,持续监控git库中的yaml和 registry的镜像

It fills the automation void that exists between building and monitoring.
Automated git->cluster synchronisation


配置存储库的同步

Flux的主要特性是版本控制存储库和集群之间的自动同步。如果对存储库进行任何更改,这些更改将自动部署到集群中。

所有配置都存储在版本控制中,并且本质上是最新的。在任何时候,任何人都可以完全以完全相同的配置状态重新创建集群。
对集群的更改对所有相关方都是立即可见的。
在事后分析期间,git日志为审计提供了完美的历史记录。
端到端,代码到生产管道不仅变得可能,而且容易。


配置容器的自动部署

另一个特性是容器的自动部署。它将持续监控一系列容器注册中心,并在适用的地方部署新版本。
这对于使存储库和集群保持最新非常有用。它允许单独的团队拥有自己的部署管道,因为Flux能够看到新映像并相应地更新集群。
可以禁用此功能,并将图像锁定到特定的版本。


集成其他配置工具,内置支持Kustomize和Helm

对于跨环境和集群的配置自定义,Flux提供了对Kustomize和Helm的内置支持。
对于高级部署模式,如Canary版本、A/B测试和蓝/绿部署,Flux可以和Flagger一起使用。


要求和局限性:

Requirements and limitations

  1. 目前一次只能处理一个库,技术限制,不会是永久问题
  2. 会忽略 heml/chart ,文件夹包含Chart.yaml and values.yaml 就会被跳过。
  3. 只能处理yaml 文件,会递归目录中的yaml 文件,不会解析文件夹结构意义
  4. 由于Flux在集群中的一个容器中运行,所以它可能无法解析您或Kubernetes能够解析的所有主机名。特别是,它将无法在localhost上提供
2020-04-09 13:49:47    493    0    0


 

ConfigMaps allow you to decouple configuration artifacts from image content to keep containerized applications portable. This page provides a series of usage examples demonstrating how to create ConfigMaps and configure Pods using data stored in ConfigMaps.

ConfigMaps允许您将配置构件与映像内容解耦,以保持容器化应用程序的可移植性。这个页面提供了一系列使用示例,演示如何使用ConfigMaps中存储的数据创建ConfigMaps和配置Pods。

 

用kubectl create configmap创建

kubectl create configmap <map-name> <data-source>

 

--from-file

--from-file 可以跟路径,可以跟单个文件,可以多次使用跟多个文件

 
mkdir -p configure-pod-container/configmap/
# Download the sample files into `configure-pod-container/configmap/` directory
wget https://kubernetes.io/examples/configmap/game.properties -O configure-pod-container/configmap/game.properties
wget https://kubernetes.io/examples/configmap/ui.properties -O configure-pod-container/configmap/ui.properties
# Create the configmap
kubectl create configmap game-config --from-file=configure-pod-container/configmap/
kubectl create configmap game-config-2 --from-file=config
? k8s ?    2020-04-07 11:42:30    589    0    0

 

flagger

https://github.com/weaveworks/flagger

主要是推进
Flagger是Kubernetes公司的运营商,该公司使用Istio、Linkerd、App Mesh、NGINX、等高线或Gloo路由来自动提升canary部署,并使用Prometheus指标进行canary分析。canary分析可以通过webhook进行扩展,以运行验收测试、负载测试或任何其他自定义验证。

https://docs.flagger.app/

https://docs.flagger.app/usage/how-it-works

flagger 可以通过配置一个名为canary的自定义资源,将Kubernetes工作负载的发布过程自动化。

A canary resource can target a Kubernetes Deployment or DaemonSet.

Kubernetes Deployment example:

Based on the above configuration, Flagger generates the following Kubernetes objects:

  • deployment/<targetRef.name>-primary

  • hpa/<autoscalerRef.name>-primary

Flagger will detect changes to the target deployment (including secrets and configmaps) and will perform a canary analysis before promoting the new version as primary.

If the target deployment uses secrets and/or configmaps, Flagger will create a copy of each object using the -primary prefix and will reference these objects in the primary deployment、

Note that the target deployment must have a single label selector in th

? k8s ?    2020-03-31 14:04:14    2872    0    3

项目源码:

https://github.com/tektoncd/pipeline

The Tekton Pipelines project provides k8s-style resources for declaring CI/CD-style pipelines.
Tekton管道项目为声明CI/ cd风格的管道提供了k8风格的资源。


 

 安装

Install Tekton Pipelines

kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml

Install Tekton CLI (tkn)

curl -LO https://github.com/tektoncd/cli/releases/download/v0.7.1/tkn_0.7.1_Linux_x86_64.tar.gz

# Change destination directory as needed
tar xvzf tkn_0.7.1_Linux_x86_64.tar.gz -C ~/bin
​

Install Tekton dashboard 仪表盘

kubectl apply --filename https://github.com/tektoncd/dashboard/releases/download/v0.5.1/tekton-dashboard-release.yaml


更改镜像源

默认镜像源安装时的问题解决:

其中:https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml

https://github.com/tektoncd/dashboard/releases/download/v0.5.1/tekton-dashboard-release.yaml

两个yaml 中创建资源时,pull 镜像用的镜像库是国外的,gcr.io 需要替换成国内的镜像源:gcr.azk8s.cn

如果使用原来的gcr.io , 资源创建成功后在启动的过程中,pod状态一直是 imagepullbackoff , 查看pod 内部,是无法pull 镜像所致。

get pods --na
1/3