Skip to content

Commit

Permalink
bak
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzi68 committed Nov 13, 2024
1 parent 2ed51ab commit 41fddc0
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 13 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
3. jenkins-libs,Jenkins共享库
4. jenkins-pipeline,pipeline流水线,实现从代码编译 → 打包镜像 → 修改kustomize → 提交kustomize到gitlab仓库

代码仓库:

![](../images/Snipaste_2024-11-13_17-17-10.jpg)
![](../images/Snipaste_2024-11-13_17-18-20.jpg)
2 changes: 1 addition & 1 deletion hx-kustomize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

## argocd 部署

![](../images/demo-images/Snipaste_2024-11-13_11-39-12.jpg)
![](..images/demo-images/Snipaste_2024-11-13_17-16-14.jpg)
![](../images/demo-images/Snipaste_2024-11-13_11-39-40.jpg)
4 changes: 0 additions & 4 deletions hx-kustomize/overlays/staging/kustomization.yaml

This file was deleted.

Empty file.
11 changes: 11 additions & 0 deletions hx-kustomize/overlays/staging1/change-pvc.patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hx-chat-action-server-data-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storageClassName: nfs-client
25 changes: 25 additions & 0 deletions hx-kustomize/overlays/staging1/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: hx-staging-1
labels:
- pairs:
owner: colin
version: 20241021-v0.0.1
replicas:
- name: hx-chat-action-server
count: 1
images:
- name: hx-chat-action-server
newName: nginx
newTag: 1.27.2
resources:
- ../../base
configMapGenerator:
- name: hx-chat-action-server-configmap
behavior: merge
literals:
- RUST_LOG=DEBUG
patches:
- path: change-pvc.patch.yaml
transformers:
- ./kustomizeconfig/namesuffix-transformer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: builtin
kind: PrefixSuffixTransformer
metadata:
name: name-suffix-transformer
suffix: -staging-1
fieldSpecs:
- path: metadata/name
kind: Deployment
- path: metadata/name
kind: ConfigMap
- path: metadata/name
kind: Service
- path: metadata/name
kind: PersistentVolumeClaim
Binary file added images/Snipaste_2024-11-13_17-17-10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Snipaste_2024-11-13_17-18-20.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/demo-images/Snipaste_2024-11-13_11-39-12.jpg
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion jenkins-pipeline/hx-nlp-chat/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@

```bash

kubectl apply -n argocd -f application.yaml
ubuntu@k8s-master01:~/test-argocd$ kubectl delete -f argocd-declarative/application-hx-dev-1.yaml
application.argoproj.io "hx-chat-action-server" deleted
ubuntu@k8s-master01:~/test-argocd$ kubectl apply -f argocd-declarative/application-hx-dev-1.yaml
Warning: metadata.finalizers: "resources-finalizer.argocd.argoproj.io": prefer a domain-qualified finalizer name to avoid accidental conflicts with other finalizer writers
application.argoproj.io/hx-chat-action-server-dev-1 created


ubuntu@k8s-master01:~/test-argocd$ kubectl apply -f argocd-declarative/application-hx-staging-1.yaml
application.argoproj.io/hx-chat-action-server-staging-1 configured


```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: argoproj.io/v1alpha1
kind: Application
# https://argo-cd.readthedocs.io/en/stable/user-guide/application-specification/
metadata:
name: hx-chat-action-server
name: hx-chat-action-server-dev-1
# You'll usually want to add your resources to the argocd namespace.
#+ 这里配置为:hx-dev-1,放到服务所部署的命名空间下,相应的kind: AppProject中,需要进行匹配修改
namespace: hx-dev-1
Expand All @@ -14,7 +14,7 @@ metadata:
# - resources-finalizer.argocd.argoproj.io/background
# Add labels to your application object.
labels:
name: hx-chat-action-server
name: hx-chat-action-server-dev-1
spec:
# The project the application belongs to.
project: hx-chat-project
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
# https://argo-cd.readthedocs.io/en/stable/user-guide/application-specification/
metadata:
name: hx-chat-action-server-staging-1
# You'll usually want to add your resources to the argocd namespace.
#+ 这里配置为:hx-dev-1,是指把这个声明式的 Application 放到 hx-dev-1 下。
#+ 相应的kind: AppProject中,需要进行匹配修改
namespace: hx-dev-1
# Add this finalizer ONLY if you want these to cascade delete.
finalizers:
# The default behaviour is foreground cascading deletion
- resources-finalizer.argocd.argoproj.io
# Alternatively, you can use background cascading deletion
# - resources-finalizer.argocd.argoproj.io/background
# Add labels to your application object.
labels:
name: hx-chat-action-server-staging-1
spec:
# The project the application belongs to.
project: hx-chat-project

# Source of the application manifests
source:
repoURL: ssh://git@iamIPaddr:50022/argocd/hx-kustomize.git # Can point to either a Helm chart repo or a git repo.
targetRevision: main # For Helm, this refers to the chart version.
path: overlays/staging1 # This has no meaning for Helm charts pulled directly from a Helm repo instead of git.

# Destination cluster and namespace to deploy the application
destination:
# cluster API URL
server: https://kubernetes.default.svc
# or cluster name
# name: in-cluster
# The namespace will only be set for namespace-scoped resources that have not set a value for .metadata.namespace
namespace: hx-staging-1

# Extra information to show in the Argo CD Application details tab
info:
- name: '备注:'
value: '测试数据'

# Sync policy
syncPolicy:
automated: # automated sync by default retries failed attempts 5 times with following delays between attempts ( 5s, 10s, 20s, 40s, 80s ); retry controlled using `retry` field.
prune: true # Specifies if resources should be pruned during auto-syncing ( false by default ).
selfHeal: true # Specifies if partial app sync should be executed when resources are changed only in target Kubernetes cluster and no git change detected ( false by default ).
allowEmpty: false # Allows deleting all application resources during automatic syncing ( false by default ).
syncOptions: # Sync options which modifies sync behavior
- Validate=false # disables resource validation (equivalent to 'kubectl apply --validate=false') ( true by default ).
- CreateNamespace=true # Namespace Auto-Creation ensures that namespace specified as the application destination exists in the destination cluster.
- PrunePropagationPolicy=foreground # Supported policies are background, foreground and orphan.
- PruneLast=true # Allow the ability for resource pruning to happen as a final, implicit wave of a sync operation
- RespectIgnoreDifferences=true # When syncing changes, respect fields ignored by the ignoreDifferences configuration
- ApplyOutOfSyncOnly=true # Only sync out-of-sync resources, rather than applying every object in the application
managedNamespaceMetadata: # Sets the metadata for the application namespace. Only valid if CreateNamespace=true (see above), otherwise it's a no-op.
labels: # The labels to set on the application namespace
who: zhangsan
annotations: # The annotations to set on the application namespace
annotations: demo

# The retry feature is available since v1.7
retry:
limit: 5 # number of failed sync attempt retries; unlimited number of attempts if less than 0
backoff:
duration: 5s # the amount to back off. Default unit is seconds, but could also be a duration (e.g. "2m", "1h")
factor: 2 # a factor to multiply the base duration after each failed retry
maxDuration: 3m # the maximum amount of time allowed for the backoff strategy

# Will ignore differences between live and desired states during the diff. Note that these configurations are not
# used during the sync process unless the `RespectIgnoreDifferences=true` sync option is enabled.
ignoreDifferences:
# for the specified json pointers
- group: apps
kind: Deployment
jsonPointers:
- /spec/replicas
# for the specified managedFields managers
- group: "*"
kind: "*"
managedFieldsManagers:
- kube-controller-manager

# RevisionHistoryLimit limits the number of items kept in the application's revision history, which is used for
# informational purposes as well as for rollbacks to previous versions. This should only be changed in exceptional
# circumstances. Setting to zero will store no history. This will reduce storage used. Increasing will increase the
# space used to store the history, so we do not recommend increasing it.
revisionHistoryLimit: 10
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
# Only permit applications to deploy to the guestbook namespace in the same cluster
# Destination clusters can be identified by 'server', 'name', or both.
destinations:
- namespace: hx-dev-1
- namespace: '*'
## 默认的k8s集群,argocd所在的k8s集群,其名称就是:in-cluster
#+ 可以通过argocd CLI添加k8s集群
server: https://kubernetes.default.svc
Expand Down
9 changes: 5 additions & 4 deletions jenkins-pipeline/hx-nlp-chat/hx-chat-action-server.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,12 @@ pipeline {
configEnvPrefix = configEnv[0]
configEnvSuffix = configEnv[1]
configENV = configEnv[2]
println("CONFIG_ENV:" + configEnvSuffix)
println("项目简称,用于命名空间的前缀:" + configEnvPrefix)
println("CONFIG_ENV,configEnvSuffix:" + configEnvSuffix)
println("项目简称,用于命名空间的前缀,configEnvPrefix:" + configEnvPrefix)
println("configENV:" + configENV)
switch(configENV) {
case 'staging':
kustomizationYaml = "overlays/staging/kustomization.yaml"
case 'staging1':
kustomizationYaml = "overlays/staging1/kustomization.yaml"
break
/* 生产环境根据各自发版流程决定是否在这里处理
case 'prod':
Expand Down

0 comments on commit 41fddc0

Please sign in to comment.