diff --git a/.idea/misc.xml b/.idea/misc.xml index dbc2f9c237b641f11a647778094e018ee6f2d5c3..fb866c38509b2e2e64a52847085bcd3fd7cf0b50 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -9,7 +9,7 @@ - + \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index cc9ef25c7efe51acd4db715062cf8c6281a24f93..a7618a27879a7cb4b01019c8c993ca887452320f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,17 +1,42 @@ pipeline { agent any - environment { - IMAGE_REPO="penhaijun/k8slogging-app" - GIT_CREDENTIAL_ID='c3fb3a1b-ac61-4114-8209-796d6f1004d8' - } - - + environment { + // 镜像仓库名 + IMAGE_REPO="penhaijun/k8slogging-app" + // 提交到 git 时的用户名和密码 + BUILD_USER = 'jenkins' + BUILD_USER_EMAIL = 'jenkins@Argo CD.com' + // 发布的配置文件的 GIT REPO 及GIT 库的凭证ID + GIT_CREDENTIAL_ID='c3fb3a1b-ac61-4114-8209-796d6f1004d8' + YAML_REPO_URL='https://${username}:${password}@gitee.com/haijun12/argo-cd-git.git' + KEY_WORD='Code makes me happy' + } triggers { // 每分钟 pollSCM('H/2 * * * *') } stages { + + // 检查提交的 mark 中是否启有指定的魔术值 + stage("check Magic Value"){ + environment { + COMMIT_ID = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim() + MESSAGE= sh(returnStdout: true, script: "git log --pretty=format:“%s” ${COMMIT_ID} -1").trim() + } + steps{ + sh """ + if echo "$MESSAGE" | grep -q -E '${KEY_WORD}$' + then + echo "开始构建..." + else + echo "没有魔法值,退出..." + exit 0 + fi + """ + } + } + // 编译 JAVA 代码 stage('Build image') { steps { @@ -28,73 +53,32 @@ pipeline { } } - // checkout 配置库 -// stage ('checkout config repo ...') { -// environment { -// // config repo url -// GIT_CONFIG_REPO_URL='https://gitee.com/haijun12/argo-cd-git.git' -// } -// -// steps { -// script { -// def exists = fileExists 'argo-cd-git' -// if (!exists){ -// sh "mkdir argo-cd-git" -// // new File('argo-cd-git').mkdir() -// } -// } -// -// dir('argo-cd-git') { -// checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: "${GIT_CREDENTIAL_ID}", url: "${GIT_CONFIG_REPO_URL}"]]]) -// sh "git chekout " -// } -// sh "pwd" -// } -// } - - - // 修改发布的 git repository - // uat,sit,prd 都修改git repository,只是prd的cd 手动触发 - // 更改demo-config库下demo/demo.yaml文件内镜像tag - // 提交更改至demo-config库 + // 修改发布的 git repository + // uat,sit,prd 都修改git repository,只是prd的cd 手动触发 + // 更改demo-config库下demo/demo.yaml文件内镜像tag + // 提交更改至demo-config库 stage('update docker tag') { environment { - BUILD_USER = 'jenkins' - BUILD_USER_EMAIL = 'jenkins@Argo CD.com' - // YAML_REPO_URL='http://${username}:${password}@10.39.140.196:10080/gogs/argocd-gitops.git' - YAML_REPO_URL='https://${username}:${password}@gitee.com/haijun12/argo-cd-git.git' + // 获取的是代码的提交Id COMMIT_ID = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim() - // env.TIMESTRAP = sh(returnStdout: true, script: 'date +%Y%m%d%H%M%S').trim() - TIMESTRAP = sh(returnStdout: true, script: 'date "+%Y-%m-%d %H:%M:%S"').trim() - // env.DOCKER_TAG = "dev_${TIMESTRAP}_${COMMIT_ID}_${BUILD_NUMBER}" + // 取得当前时间 + TIMESTAMP = sh(returnStdout: true, script: 'date "+%Y-%m-%d %H:%M:%S"').trim() + // 取得 将要更改的 yaml 文件名 FILE_NAME = sh(returnStdout:true, script:"echo deployment-`[[ ${BRANCH_NAME} == master ]] && echo sit || echo ${BRANCH_NAME}`").trim() - // 读取 target>docker>tag 文件内容 + // 读取image的TAG 从 target>docker>tag 文件中读取 DOCKER_TAG=sh(returnStdout:true, script:"cat k8slogging-app/target/docker/tag").trim() } -// script { -// env.COMMIT_ID = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim() -// // env.TIMESTRAP = sh(returnStdout: true, script: 'date +%Y%m%d%H%M%S').trim() -// env.TIMESTRAP = sh(returnStdout: true, script: 'date "+%Y-%m-%d %H:%M:%S"').trim() -// // env.DOCKER_TAG = "dev_${TIMESTRAP}_${COMMIT_ID}_${BUILD_NUMBER}" -// -// env.FILE_NAME = sh(returnStd:true, script:"echo deployment-`[[ ${BRANCH_NAME} == master ]] && echo sit || echo ${BRANCH_NAME}`").trim() -// // 读取 target>docker>tag 文件内容 -// env.DOCKER_TAG=sh(returnStd:true, script:"cat target/docker/tag").trim() -// } - -// git clone ${YAML_REPO_URL} && cd argo-cd-git -// cd .. -// rm -rf argo-cd-git/ - steps { withCredentials([usernamePassword(passwordVariable : 'password' ,usernameVariable : 'username' ,credentialsId : "$GIT_CREDENTIAL_ID" ,)]) { + // 如果不存在则 CLONE 一个 sh """ if [ ! -d "argo-cd-git" ];then git clone ${YAML_REPO_URL} fi """ + // 在子目录里 替换IMAGE的版本号以及 annotations.buildTime dir('argo-cd-git'){ sh """ @@ -106,9 +90,11 @@ pipeline { git config --global user.name "$BUILD_USER" git config --global user.email "$BUILD_USER_EMAIL" git config --global push.default simple + sed -i "s#${IMAGE_REPO}.*#${IMAGE_REPO}:${DOCKER_TAG}#g" k8s-logging/${FILE_NAME}.yaml - sed -i "s#buildTime.*#buildTime: ${TIMESTRAP}#g" k8s-logging/${FILE_NAME}.yaml - git add -A && git commit -m "[jenkins自动更新] update image tag: []${DOCKER_TAG}] by jenkins" && git push origin master + sed -i "s#buildTime.*#buildTime: ${TIMESTAMP}#g" k8s-logging/${FILE_NAME}.yaml + + git add -A && git commit -m "[ jenkins自动更新] update image tag: []${DOCKER_TAG}] by jenkins" && git push origin master """ } } diff --git a/deploy/app-deployment.yml b/deploy/app-deployment.yml deleted file mode 100644 index 13847946cc0f06fbc435c6b7484698fb044f20cb..0000000000000000000000000000000000000000 --- a/deploy/app-deployment.yml +++ /dev/null @@ -1,189 +0,0 @@ -# service 部署方式 ---- -# 添加 filebeat 的 configmap -apiVersion: v1 -kind: ConfigMap -metadata: - name: filebeat-config - namespace: phj-test-app - labels: - k8s-app: filebeat -data: - filebeat.yml: |- - filebeat.inputs: - - type: log - enabled: true - paths: - - /logs/*/debug.log - tags: ["debug"] - - type: log - enabled: true - paths: - - /logs/*/error.log - tags: ["error"] - #processors: - # - add_kubernetes_metadata: - # host: ${NODE_NAME} - # - add_cloud_metadata: - # - add_host_metadata: - # - script: - # lang: javascript - # id: format_time - # tag: enable - # source: > - # function process(event) { - # var str=event.Get("message"); - # var time=str.split(" ").slice(0, 1).join(" "); - # event.Put("time", time); - # } - # - timestamp: - # field: time - # timezone: Asia/Shanghai - # layouts: - # - '2006-01-02 15:04:05' - # - '2006-01-02 15:04:05.999' - # test: - # - '2019-06-22 16:33:51' - # - script: - # lang: javascript - # id: format_k8s - # tag: enable - # source: > - # function process(event) { - # var k8s=event.Get("kubernetes"); - # var container=event.Get("container"); - # var host=event.Get("host"); - # var newK8s = { - # podName: k8s.pod.name, - # nameSpace: k8s.namespace, - # imageName: container.image.name, - # hostName: k8s.node.hostname, - # ip: host.ip - # } - # event.Put("k8s", newK8s); - # } - # - drop_fields: - # fields: - # - kubernetes - # - host - # - ecs - # - log - # - agent - # - input - # - container - # ignore_missing: true - - output.elasticsearch: - hosts: ['10.229.12.212:9200','10.229.12.213:9200','10.229.12.214:9200'] - username: "elastic" - password: "devops_elastic" - indices: - - index: "${POD_NAME}_debug-%{[beat.version]}-%{+yyyy.MM.dd}" - when.contains: - tags: "debug" - - index: "${POD_NAME}_error-%{[beat.version]}-%{+yyyy.MM.dd}" - when.contains: - tags: "error" - setup.template.name: "logging-app" - setup.template.pattern: "logging-app_*" - setup.template.enabled: false - setup.template.overwrite: true - - -# kubectl apply -f app-deployment.yml ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: phj-test-app - name: k8slogging-app-deployment - labels: - app: k8slogging-app -spec: - replicas: 2 - selector: - matchLabels: - app: k8slogging-app - template: - metadata: - annotations: - buildTime: 20211114091035 - labels: - app: k8slogging-app - spec: - containers: - - name: k8slogging-app - # 这里需要动态替换 - image: 10.229.12.216:8309/phj/k8slogging-app:abc - imagePullPolicy: Always - env: - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - resources: - limits: - cpu: "1" - memory: 500Mi - requests: - cpu: "0.5" - memory: 200Mi - ports: - - containerPort: 8080 - protocol: TCP - volumeMounts: - - name: applog - mountPath: /logs - - name: filebeat - image: docker.elastic.co/beats/filebeat:7.13.1 - imagePullPolicy: IfNotPresent - args: ["-c", "/etc/filebeat.yml", "-e"] - env: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - resources: - limits: - cpu: "1" - memory: 200Mi - requests: - cpu: "0.5" - memory: 100Mi - volumeMounts: - - name: config - mountPath: /etc/filebeat.yml - readOnly: true - subPath: filebeat.yml - - name: applog - mountPath: /logs - volumes: - - name: config - configMap: - defaultMode: 0640 - name: filebeat-config - - name: applog - emptyDir: {} - ---- -# 对应的service -apiVersion: v1 -kind: Service -metadata: - namespace: phj-test-app - name: k8slogging-app-service - labels: - run: k8slogging-app-service -spec: - type: NodePort - ports: - - port: 8080 - nodePort: 31080 - protocol: TCP - targetPort: 8080 - selector: - app: k8slogging-app diff --git a/k8slogging-app/pom.xml b/k8slogging-app/pom.xml index 0049a4e5afae641ca9fa80d064b69ee93b5110f2..d3e0c7e1104ee9a42556b6ac7cb2e288b9ce23d4 100644 --- a/k8slogging-app/pom.xml +++ b/k8slogging-app/pom.xml @@ -10,20 +10,14 @@ com.example.k8slogging k8slogging-app - 0.0.3${version.suffix} + 0.0.3-SNAPSHOT k8slogging k8slogging-app 1.8 - ${project.version} - penhaijun/${project.artifactId} - - ${image.repository}:${image.tag} - -SNAPSHOT - - dev + 1.4.13 @@ -66,12 +60,6 @@ - - - - - - org.springframework.boot @@ -88,23 +76,26 @@ com.spotify dockerfile-maven-plugin - 1.4.13 + ${dockerfile.version} default + build + push - penhaijun - fkueitxpl + + penhaijun + fkueitxpl - ${image.repository} + penhaijun/${project.artifactId} - ${image.tag} + ${project.version} target/${project.build.finalName}.jar @@ -116,47 +107,4 @@ - - - - - - dev - - -SNAPSHOT - dev - - - - true - - - - - - master - - -SNAPSHOT - sit - - - - - prd - - - prd - - - - - - uat - - -UAT - uat - - - - diff --git a/k8slogging-app/src/main/java/com/example/k8slogging/k8sloggingapp/K8sloggingAppApplication.java b/k8slogging-app/src/main/java/com/example/k8slogging/k8sloggingapp/K8sloggingAppApplication.java index 84bbb2ee26afaf7d7ad8c5ae813906a481b0a232..51957d95aeeb6de3d0255dce84e7e4415736fc9e 100644 --- a/k8slogging-app/src/main/java/com/example/k8slogging/k8sloggingapp/K8sloggingAppApplication.java +++ b/k8slogging-app/src/main/java/com/example/k8slogging/k8sloggingapp/K8sloggingAppApplication.java @@ -40,6 +40,6 @@ public class K8sloggingAppApplication { System.out.printf("show in stdout:【%s】%n", snow); System.err.printf("show in stderr:【%s】%n", snow); - return String.format("2222我又又又又修改了,podName: [%s]- active:[%s] - version:%s \n\r", podName, active, appVersion); + return String.format("333我又又又又修改了,podName: [%s]- active:[%s] - version:%s \n\r", podName, active, appVersion); } } diff --git a/k8slogging-app/src/main/k8s/deployment.yml b/k8slogging-app/src/main/k8s/deployment.yml deleted file mode 100644 index fb363e8f8af63fee424a2bc11f049aa063a89bda..0000000000000000000000000000000000000000 --- a/k8slogging-app/src/main/k8s/deployment.yml +++ /dev/null @@ -1,215 +0,0 @@ -# service 部署方式 ---- -# 添加 ns - -apiVersion: v1 -kind: Namespace -metadata: - # 项目名-ns-[dev/sit/uat/pro] - name: @k8s-namespace@ - labels: - app.kubernetes.io/name: @k8s-namespace@ ---- -# 添加 filebeat 的 configmap -apiVersion: v1 -kind: ConfigMap -metadata: - name: filebeat-config - namespace: @k8s-namespace@ - labels: - app: filebeat - env: @profiles.active@ # 开发、UAT、生产 - app.kubernetes.io/name: @project.artifactId@ # 多模板应用的话,即模版名,比如 XX项目的付款模块名 - app.kubernetes.io/version: @project.version@ #应用程序的当前版本(例如,语义版本,修订版哈希等 如: 5.7.21 - app.kubernetes.io/part-of: @project.name@ # 项目名 - app.kubernetes.io/component: @project.description@ # 组件名,比如 database\mq\xxl_job -data: - filebeat.yml: |- - filebeat.inputs: - - type: log - enabled: true - paths: - - /logs/*/debug.log - tags: ["debug"] - - type: log - enabled: true - paths: - - /logs/*/error.log - tags: ["error"] - processors: - - add_kubernetes_metadata: - # host: ${NODE_NAME} - # - add_cloud_metadata: - # - add_host_metadata: - # - script: - # lang: javascript - # id: format_time - # tag: enable - # source: > - # function process(event) { - # var str=event.Get("message"); - # var time=str.split(" ").slice(0, 1).join(" "); - # event.Put("time", time); - # } - # - timestamp: - # field: time - # timezone: Asia/Shanghai - # layouts: - # - '2006-01-02 15:04:05' - # - '2006-01-02 15:04:05.999' - # test: - # - '2019-06-22 16:33:51' - # - script: - # lang: javascript - # id: format_k8s - # tag: enable - # source: > - # function process(event) { - # var k8s=event.Get("kubernetes"); - # var container=event.Get("container"); - # var host=event.Get("host"); - # var newK8s = { - # podName: k8s.pod.name, - # nameSpace: k8s.namespace, - # imageName: container.image.name, - # hostName: k8s.node.hostname, - # ip: host.ip - # } - # event.Put("k8s", newK8s); - # } - # - drop_fields: - # fields: - # - kubernetes - # - host - # - ecs - # - log - # - agent - # - input - # - container - # ignore_missing: true - - output.elasticsearch: - hosts: ['10.229.12.212:9200','10.229.12.213:9200','10.229.12.214:9200'] - username: "elastic" - password: "devops_elastic" - indices: - - index: "${POD_NAME}_debug-%{[beat.version]}-%{+yyyy.MM.dd}" - when.contains: - tags: "debug" - - index: "${POD_NAME}_error-%{[beat.version]}-%{+yyyy.MM.dd}" - when.contains: - tags: "error" - setup.template.name: "logging-app" - setup.template.pattern: "logging-app_*" - setup.template.enabled: false - setup.template.overwrite: true - - -# kubectl apply -f deployment.yml ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: @k8s-namespace@ - name: @project.artifactId@-deployment - labels: - app: @project.artifactId@ - env: @profiles.active@ # 开发、UAT、生产 - app.kubernetes.io/name: @project.artifactId@ # 多模板应用的话,即模版名,比如 XX项目的付款模块名 - app.kubernetes.io/version: @project.version@ #应用程序的当前版本(例如,语义版本,修订版哈希等 如: 5.7.21 - app.kubernetes.io/part-of: @project.name@ # 项目名 - app.kubernetes.io/component: @project.description@ # 组件名,比如 database\mq\xxl_job -spec: - replicas: 1 - selector: - matchLabels: - app: @project.artifactId@ - template: - metadata: - annotations: - buildTime: @maven.build.timestamp@ - labels: - app: @project.artifactId@ - spec: - containers: - - name: @project.name@ - # 这里需要动态替换 - image: @image.name@ - imagePullPolicy: Always - env: - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - resources: - limits: - cpu: "1" - memory: 500Mi - requests: - cpu: "0.5" - memory: 200Mi - ports: - - containerPort: 8080 - protocol: TCP - volumeMounts: - - name: applog - mountPath: /logs - - name: filebeat - image: docker.elastic.co/beats/filebeat:7.13.1 - imagePullPolicy: IfNotPresent - args: [ "-c", "/etc/filebeat.yml", "-e" ] - env: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - resources: - limits: - cpu: "1" - memory: 200Mi - requests: - cpu: "0.5" - memory: 100Mi - volumeMounts: - - name: config - mountPath: /etc/filebeat.yml - readOnly: true - subPath: filebeat.yml - - name: applog - mountPath: /logs - volumes: - - name: config - configMap: - defaultMode: 0640 - name: filebeat-config - - name: applog - emptyDir: { } - ---- -# 对应的service -apiVersion: v1 -kind: Service -metadata: - namespace: @k8s-namespace@ - name: @project.artifactId@-service - labels: - app: @project.artifactId@ - env: @profiles.active@ # 开发、UAT、生产 - app.kubernetes.io/name: @project.artifactId@ - app.kubernetes.io/version: @project.version@ - app.kubernetes.io/part-of: @project.name@ - app.kubernetes.io/component: @project.description@ # 组件名,比如 database\mq\xxl_job -spec: - type: NodePort - selector: - app: @project.artifactId@ - ports: - - port: 8080 - nodePort: @service.port@ - protocol: TCP - targetPort: 8080 - diff --git a/k8slogging-app/src/main/k8s/filebeat-daemonSet.yml b/k8slogging-app/src/main/k8s/filebeat-daemonSet.yml deleted file mode 100644 index 83ee60d10c23c93d702d54751b6b742afed96a1d..0000000000000000000000000000000000000000 --- a/k8slogging-app/src/main/k8s/filebeat-daemonSet.yml +++ /dev/null @@ -1,231 +0,0 @@ - -@image.name@ ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: filebeat-config - namespace: kube-system - labels: - k8s-app: filebeat -data: - filebeat.yml: |- - filebeat.inputs: - - type: container - paths: - - /var/log/containers/*.log - processors: - - add_kubernetes_metadata: - host: ${NODE_NAME} - matchers: - - logs_path: - logs_path: "/var/log/containers/" - - # To enable hints based autodiscover, remove `filebeat.inputs` configuration and uncomment this: - #filebeat.autodiscover: - # providers: - # - type: kubernetes - # node: ${NODE_NAME} - # hints.enabled: true - # hints.default_config: - # type: container - # paths: - # - /var/log/containers/*${data.kubernetes.container.id}.log - - processors: - - add_cloud_metadata: - - add_host_metadata: - - cloud.id: ${ELASTIC_CLOUD_ID} - cloud.auth: ${ELASTIC_CLOUD_AUTH} - - output.elasticsearch: - hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}'] - username: ${ELASTICSEARCH_USERNAME} - password: ${ELASTICSEARCH_PASSWORD} ---- -apiVersion: apps/v1 -kind: DaemonSet -metadata: - name: filebeat - namespace: kube-system - labels: - k8s-app: filebeat -spec: - selector: - matchLabels: - k8s-app: filebeat - template: - metadata: - labels: - k8s-app: filebeat - spec: - serviceAccountName: filebeat - terminationGracePeriodSeconds: 30 - hostNetwork: true - dnsPolicy: ClusterFirstWithHostNet - containers: - - name: filebeat - image: docker.elastic.co/beats/filebeat:7.15.1 - args: [ - "-c", "/etc/filebeat.yml", - "-e", - ] - env: - - name: ELASTICSEARCH_HOST - value: elasticsearch - - name: ELASTICSEARCH_PORT - value: "9200" - - name: ELASTICSEARCH_USERNAME - value: elastic - - name: ELASTICSEARCH_PASSWORD - value: changeme - - name: ELASTIC_CLOUD_ID - value: - - name: ELASTIC_CLOUD_AUTH - value: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - securityContext: - runAsUser: 0 - # If using Red Hat OpenShift uncomment this: - #privileged: true - resources: - limits: - memory: 200Mi - requests: - cpu: 100m - memory: 100Mi - volumeMounts: - - name: config - mountPath: /etc/filebeat.yml - readOnly: true - subPath: filebeat.yml - - name: data - mountPath: /usr/share/filebeat/data - - name: varlibdockercontainers - mountPath: /var/lib/docker/containers - readOnly: true - - name: varlog - mountPath: /var/log - readOnly: true - volumes: - - name: config - configMap: - defaultMode: 0640 - name: filebeat-config - - name: varlibdockercontainers - hostPath: - path: /var/lib/docker/containers - - name: varlog - hostPath: - path: /var/log - # data folder stores a registry of read status for all files, so we don't send everything again on a Filebeat pod restart - - name: data - hostPath: - # When filebeat runs as non-root user, this directory needs to be writable by group (g+w). - path: /var/lib/filebeat-data - type: DirectoryOrCreate ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: filebeat -subjects: - - kind: ServiceAccount - name: filebeat - namespace: kube-system -roleRef: - kind: ClusterRole - name: filebeat - apiGroup: rbac.authorization.k8s.io ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: filebeat - namespace: kube-system -subjects: - - kind: ServiceAccount - name: filebeat - namespace: kube-system -roleRef: - kind: Role - name: filebeat - apiGroup: rbac.authorization.k8s.io ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: filebeat-kubeadm-config - namespace: kube-system -subjects: - - kind: ServiceAccount - name: filebeat - namespace: kube-system -roleRef: - kind: Role - name: filebeat-kubeadm-config - apiGroup: rbac.authorization.k8s.io ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: filebeat - labels: - k8s-app: filebeat -rules: - - apiGroups: [""] # "" indicates the core API group - resources: - - namespaces - - pods - - nodes - verbs: - - get - - watch - - list - - apiGroups: ["apps"] - resources: - - replicasets - verbs: ["get", "list", "watch"] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: filebeat - # should be the namespace where filebeat is running - namespace: kube-system - labels: - k8s-app: filebeat -rules: - - apiGroups: - - coordination.k8s.io - resources: - - leases - verbs: ["get", "create", "update"] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: filebeat-kubeadm-config - namespace: kube-system - labels: - k8s-app: filebeat -rules: - - apiGroups: [""] - resources: - - configmaps - resourceNames: - - kubeadm-config - verbs: ["get"] ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: filebeat - namespace: kube-system - labels: - k8s-app: filebeat ---- \ No newline at end of file diff --git a/k8slogging-app/src/main/resources/application.yml b/k8slogging-app/src/main/resources/application.yml index 4f11e34d1038914abe3cfb13c59483e238be96e7..6b38d30468b2d003df1dab104615595cd220f08d 100644 --- a/k8slogging-app/src/main/resources/application.yml +++ b/k8slogging-app/src/main/resources/application.yml @@ -2,7 +2,7 @@ spring: application: name: @artifactId@ profiles: - active: @profiles.active@ + active: dev app: version: @project.version@ POD_NAME: macbookpro \ No newline at end of file diff --git a/k8slogging-app/src/main/resources/logback-spring.xml b/k8slogging-app/src/main/resources/logback-spring.xml index 786a5d22ddea7c6ed5e84fff9ccc190f3c137962..8441d3d2a9afd82fd11d3dc7917c4c6903ebbc51 100755 --- a/k8slogging-app/src/main/resources/logback-spring.xml +++ b/k8slogging-app/src/main/resources/logback-spring.xml @@ -36,7 +36,7 @@ ${CONSOLE_LOG_PATTERN} - + UTF-8