Skip to content

Commit

Permalink
⚡️ :: xquare-application, role
Browse files Browse the repository at this point in the history
⚡️ :: xquare-role
  • Loading branch information
rlaisqls committed Aug 26, 2023
1 parent 669236a commit f1f0942
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
paths:
- "helm/**"
- "charts/**"

permissions:
contents: read
Expand Down
50 changes: 27 additions & 23 deletions charts/xquare-application/templates/argocd-application.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
{{- range .Values.projects }}
{{ $projectName := .name }}
{{- range .applications }}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: xquare
name: {{ .name }}
namespace: argocd
spec:
destination:
namespace: argocd
server: https://kubernetes.default.svc
project: xquare
project: {{ $projectName }}
source:
path: deploy
repoURL: https://github.com/team-xquare/xquare-gitops-repo.git
targetRevision: HEAD
path: {{ .source.path }}
repoURL: {{ .source.repoURL }}
targetRevision: {{ .source.rtargetRevision }}
syncPolicy:
automated:
prune: true
selfHeal: true

prune: {{ .syncPolicy.prune }}
selfHeal: {{ .syncPolicy.selfHeal }}
{{- end }}
---
apiVersion: argoproj.io/v1alpha1
kind: Application
kind: AppProject
metadata:
name: {{ .Values.application.name }}
namespace: {{ .Values.application.namespace }}
name: {{ $projectName }}
namespace: argocd
# Finalizer that ensures that project is not deleted until it is not referenced by any application
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
namespace: {{ .Values.application.namespace }}
server: https://kubernetes.default.svc
project: {{ .Values.application.project }}
source:
path: {{ .Values.application.source.path }}
repoURL: {{ .Values.application.source.repoURL }}
targetRevision: {{ .Values.application.source.targetRevision }}
syncPolicy:
automated:
prune: {{ .Values.application.syncPolicy.automated.prune }}
selfHeal: {{ .Values.application.syncPolicy.automated.selfHeal }}
sourceRepos:
- '*'
destinations:
- namespace: '*'
server: '*'
clusterResourceWhitelist:
- group: '*'
kind: '*'
{{- end }}
17 changes: 0 additions & 17 deletions charts/xquare-application/templates/argocd-project.yaml

This file was deleted.

23 changes: 23 additions & 0 deletions charts/xquare-application/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
projects:
- name: xquare-application
applications:
- name: xquare
source:
path: deploy
repoURL: https://github.com/team-xquare/xquare-gitops-repo.git
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
- name: xquare-k8s-resources
applications:
- name: xquare-role
source:
path: charts/xquare-role
repoURL: https://github.com/team-xquare/k8s-resource.git
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
6 changes: 6 additions & 0 deletions charts/xquare-role/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
type: application
name: xquare-role
version: 1.0.1
appVersion: "1.0.0"
description: Xquare role
45 changes: 45 additions & 0 deletions charts/xquare-role/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- range .Values.clubs }}
{{- $clubname := .name }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace:
name: {{ $clubname }}-role
rules:
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "list"]
resourceNames:
{{- range .deployments }}
- name: {{ . }}
{{- end }}
{{- range .users }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ $clubname }}-rolebinding
namespace: xquare-prod
subjects:
- kind: User
name: {{ . }}
roleRef:
kind: Role
name: {{ $clubname }}-pod-read-and-logs
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ $clubname }}-rolebinding
namespace: xquare-stag
subjects:
- kind: User
name: {{ . }}
roleRef:
kind: Role
name: {{ $clubname }}-pod-read-and-logs
apiGroup: rbac.authorization.k8s.io
{{- end }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/xquare-role/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
clubs:
- name: dms
deployments:
- "feed-fe-prod"
users:
- "[email protected]"

0 comments on commit f1f0942

Please sign in to comment.