Argo Workflows 安装
kubectl create ns argo
kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo-workflows/stable/manifests/quick-start-postgres.yaml
kubectl -n argo port-forward deployment/argo-server 2746:2746
kubectl create ns argo
kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo-workflows/stable/manifests/quick-start-postgres.yaml
kubectl -n argo port-forward deployment/argo-server 2746:2746
这里使用的是测试仓库(private)
https://github.com/zl86790/argocdtest.git
注意这个仓库不能为空,否则一会儿会被提示一个 empty repository错误
使用argocd连接这个repo
选择Repository
选择 CONNECT REPO USING SSH
ssh-keygen -t rsa -b 4096
id_rsa -> argocd
id_rsa.pub -> github
会得到如下连接
创建一个 application
配置如下
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: argocdtest
spec:
destination:
name: ''
namespace: ''
server: 'https://kubernetes.default.svc'
source:
path: ./
repoURL: 'git@github.com:zl86790/argocdtest.git'
targetRevision: HEAD
project: default
syncPolicy:
automated: null
在repo中追加一个新文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: argocdtest
spec:
selector:
matchLabels:
app: web_server
replicas: 2
template:
metadata:
labels:
app: web_server
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
点击 REFRESH 会看到
点击 同步 SYNC
可以看到Nginx已经正确部署了
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl port-forward --address 0.0.0.0 svc/argocd-server -n argocd 8000:443
用户名 admin
密码是 Pod 名
kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2
argocd-server-86f7f94488-pv2zk
不过我这里不好用,查看了一下 secrets 发现密码是 HclJUPjSiSwmWZpC
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
kubectl create namespace cattle-system
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.0.4/cert-manager.crds.yaml
kubectl create namespace cert-manager
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--version v1.0.4
helm install rancher rancher-latest/rancher \
--namespace cattle-system \
--set hostname=rancher.lizhe.com
pipeline {
agent none
environment {
SONAR_LOGIN='xxxxxxxxxxxxxxxxxxxxxx'
}
stages {
stage ('Checkout') {
agent any
steps {
sh "rm -rf /var/jenkins_home/workspace/${env.JOB_NAME}/*"
git branch: 'develop', credentialsId: 'xxxxxxxxxxxxxxxxxxxx', url: 'https://github.com/xxxxxx/xxxxxxxx.git'
}
}
stage('Scan') {
agent {
docker {
image 'docker:20.10.6'
args "-v /var/run/docker.sock:/var/run/docker.sock -v /var/jenkins_home/workspace/${env.JOB_NAME}/:/usr/src"
}
}
steps {
dir("/var/jenkins_home/workspace/${env.JOB_NAME}/") {
sh """
ls /usr/src
rm -rf /usr/src/*
ls /usr/src
ls /var/jenkins_home/workspace/${env.JOB_NAME}
cp -r /var/jenkins_home/workspace/${env.JOB_NAME}/* /usr/src/
ls /usr/src
docker run --rm -e SONAR_HOST_URL="http://10.10.10.198:9000/" -e SONAR_LOGIN='${env.SONAR_LOGIN}' -v /var/jenkins_home/workspace/${env.JOB_NAME}/:/usr/src sonarsource/sonar-scanner-cli \
-Dsonar.projectKey=app-sonarqube -Dsonar.sources=./
"""
}
}
}
}
}
microk8s enable prometheus
如果安装过程中报错,尝试删除相关文件夹
sudo rm -rf /var/snap/microk8s/2262/kube-prometheus
使用 kubectl port-forward 登入
microk8s kubectl port-forward grafana-6b8df57c5b-z626n 3000:3000 -n monitoring
输入系统刚才提示的密码
admin/admin
创建一个 nodeport
kind: Service
apiVersion: v1
metadata:
name: grafananp
namespace: monitoring
labels:
app: grafana
spec:
ports:
- name: http
protocol: TCP
port: 3000
targetPort: 3000
nodePort: 30036
selector:
app: grafana
type: NodePort
sessionAffinity: None
externalTrafficPolicy: Cluster