Skip to content

Commit

Permalink
feat(shulker-addon-matchmaking): create director and mmf (#210)
Browse files Browse the repository at this point in the history
* feat(shulker-addon-matchmaking): create director and mmf

* test(shulker-addon-matchmaking): cover batch mmf
  • Loading branch information
jeremylvln authored Nov 9, 2023
1 parent d3231d4 commit 72cd61f
Show file tree
Hide file tree
Showing 61 changed files with 2,638 additions and 75 deletions.
8 changes: 4 additions & 4 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ linker = "x86_64-linux-gnu-gcc"
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

[target.'cfg(all())']
rustflags = [
"-Wunused_crate_dependencies",
]
# [target.'cfg(all())']
# rustflags = [
# "-Wunused_crate_dependencies",
# ]
7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"[rust]": {
"editor.tabSize": 4,
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true,
"editor.formatOnSave": true
},
"rust-analyzer.check.command": "clippy",
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": ".github/workflows/deploy.yml",
"https://json.schemastore.org/github-issue-config.json": ".github/ISSUE_TEMPLATE/config.yml"
}
}
},
"rust-analyzer.cargo.features": "all"
}
27 changes: 27 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ anyhow = "1.0.75"
async-trait = "0.1.74"
base64 = "0.21.5"
chrono = { version = "0.4.31", features = ["serde"] }
clap = { version = "4.4.7", features = ["derive"] }
clap = { version = "4.4.7", features = ["derive", "env"] }
futures = "0.3.29"
futures-core = "0.3.29"
hostname = "0.3.1"
http = "0.2.9"
hyper = "0.14.27"
insta = { version = "1.34.0", features = ["yaml", "toml", "redactions"] }
k8s-openapi = { version = "0.20.0", features = ["latest", "schemars"] }
kube = { version = "0.87.1", features = ["runtime", "client", "derive" ] }
lazy_static = "1.4.0"
paste = "1.0.14"
pbjson-types = "0.6.0"
prometheus = "0.13.3"
prost = "0.12.1"
Expand All @@ -50,11 +52,14 @@ serde = { version = "1.0.192", features = ["derive"] }
serde_json = "1.0.108"
serde_yaml = "0.9.27"
strum = { version = "0.25.0", features = ["derive"] }
tempfile = "3.8.1"
thiserror = "1.0.50"
tonic = { version = "0.10.2", features = ["gzip"] }
tokio = { version = "1.33.0", features = ["macros", "rt-multi-thread"] }
tokio-stream = "0.1.14"
tokio-util = "0.7.10"
toml = "0.8.8"
tower = "0.4.13"
tower-test = "0.4.0"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.17", features = ["json", "env-filter"] }
Expand Down
3 changes: 3 additions & 0 deletions kube/overlays/next/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ namespace: shulker-system
resources:
- ../../resources/crd
- ../../resources/components/shulker-operator
- ../../resources/components/shulker-addon-matchmaking

images:
- name: ghcr.io/jeremylvln/shulker-operator
newTag: next
- name: ghcr.io/jeremylvln/shulker-addon-matchmaking
newTag: next
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: shulker-addon-matchmaking-director
labels:
app.kubernetes.io/name: deployment
app.kubernetes.io/instance: shulker-addon-matchmaking-director
app.kubernetes.io/component: shulker-addon-matchmaking
app.kubernetes.io/part-of: shulker
spec:
selector:
matchLabels:
app.kubernetes.io/name: shulker-addon-matchmaking-director
app.kubernetes.io/instance: shulker-addon-matchmaking-director
app.kubernetes.io/component: shulker-addon-matchmaking
replicas: 1
template:
metadata:
labels:
app.kubernetes.io/name: shulker-addon-matchmaking-director
app.kubernetes.io/instance: shulker-addon-matchmaking-director
app.kubernetes.io/component: shulker-addon-matchmaking
spec:
containers:
- name: shulker-addon-matchmaking-director
image: ghcr.io/jeremylvln/shulker-addon-matchmaking
imagePullPolicy: Always
args:
- --metrics-bind-address=0.0.0.0:8080
env:
- name: OPEN_MATCH_BACKEND_HOST
value: open-match-backend.open-match
- name: OPEN_MATCH_BACKEND_GRPC_PORT
value: '50505'
- name: SHULKER_API_HOST
value: 'shulker-operator.shulker-system'
- name: SHULKER_API_GRPC_PORT
value: '8080'
ports:
- containerPort: 8080
protocol: TCP
name: metrics
livenessProbe:
httpGet:
path: /healthz
port: metrics
periodSeconds: 15
startupProbe:
httpGet:
path: /healthz
port: metrics
failureThreshold: 5
periodSeconds: 15
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 10m
memory: 64Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- 'ALL'
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
serviceAccountName: shulker-addon-matchmaking
terminationGracePeriodSeconds: 30
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- amd64
- arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: shulker-addon-matchmaking-director-metrics
labels:
app.kubernetes.io/name: service
app.kubernetes.io/instance: shulker-addon-matchmaking-director-metrics
app.kubernetes.io/component: shulker-addon-matchmaking
app.kubernetes.io/part-of: shulker
spec:
selector:
app.kubernetes.io/name: shulker-addon-matchmaking-director
app.kubernetes.io/instance: shulker-addon-matchmaking-director
app.kubernetes.io/component: shulker-addon-matchmaking
ports:
- name: metrics
port: 8080
protocol: TCP
targetPort: metrics
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- director_deployment.yaml
- director_metrics_service.yaml
- mmf_deployment.yaml
- mmf_metrics_service.yaml
- mmf_service.yaml
- rbac/
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: shulker-addon-matchmaking-mmf
labels:
app.kubernetes.io/name: deployment
app.kubernetes.io/instance: shulker-addon-matchmaking-mmf
app.kubernetes.io/component: shulker-addon-matchmaking
app.kubernetes.io/part-of: shulker
spec:
selector:
matchLabels:
app.kubernetes.io/name: shulker-addon-matchmaking-mmf
app.kubernetes.io/instance: shulker-addon-matchmaking-mmf
app.kubernetes.io/component: shulker-addon-matchmaking
replicas: 1
template:
metadata:
labels:
app.kubernetes.io/name: shulker-addon-matchmaking-mmf
app.kubernetes.io/instance: shulker-addon-matchmaking-mmf
app.kubernetes.io/component: shulker-addon-matchmaking
spec:
containers:
- name: shulker-addon-matchmaking-mmf
image: ghcr.io/jeremylvln/shulker-addon-matchmaking
command: ['/shulker-addon-matchmaking-mmf']
imagePullPolicy: Always
args:
- --metrics-bind-address=0.0.0.0:8080
env:
- name: OPEN_MATCH_QUERY_HOST
value: open-match-query.open-match
- name: OPEN_MATCH_QUERY_GRPC_PORT
value: '50503'
ports:
- containerPort: 8080
protocol: TCP
name: metrics
- containerPort: 9090
protocol: TCP
name: mmf-batch
- containerPort: 9091
protocol: TCP
name: mmf-elo
livenessProbe:
httpGet:
path: /healthz
port: metrics
periodSeconds: 15
startupProbe:
httpGet:
path: /healthz
port: metrics
failureThreshold: 5
periodSeconds: 15
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 10m
memory: 64Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- 'ALL'
nodeSelector:
kubernetes.io/os: linux
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
serviceAccountName: shulker-addon-matchmaking
terminationGracePeriodSeconds: 30
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- amd64
- arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: shulker-addon-matchmaking-mmf-metrics
labels:
app.kubernetes.io/name: service
app.kubernetes.io/instance: shulker-addon-matchmaking-mmf-metrics
app.kubernetes.io/component: shulker-addon-matchmaking
app.kubernetes.io/part-of: shulker
spec:
selector:
app.kubernetes.io/name: shulker-addon-matchmaking-mmf
app.kubernetes.io/instance: shulker-addon-matchmaking-mmf
app.kubernetes.io/component: shulker-addon-matchmaking
ports:
- name: metrics
port: 8080
protocol: TCP
targetPort: metrics
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: Service
metadata:
name: shulker-addon-matchmaking-mmf
labels:
app.kubernetes.io/name: service
app.kubernetes.io/instance: shulker-addon-matchmaking-mmf
app.kubernetes.io/component: shulker-addon-matchmaking
app.kubernetes.io/part-of: shulker
spec:
selector:
app.kubernetes.io/name: shulker-addon-matchmaking-mmf
app.kubernetes.io/instance: shulker-addon-matchmaking-mmf
app.kubernetes.io/component: shulker-addon-matchmaking
ports:
- name: mmf-batch
port: 9090
protocol: TCP
targetPort: mmf-batch
- name: mmf-elo
port: 9091
protocol: TCP
targetPort: mmf-elo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: shulker-addon-matchmaking
labels:
app.kubernetes.io/name: servicemonitor
app.kubernetes.io/instance: shulker-addon-matchmaking
app.kubernetes.io/component: shulker-addon-matchmaking-prometheus
app.kubernetes.io/part-of: shulker
spec:
selector:
matchLabels:
app.kubernetes.io/name: service
app.kubernetes.io/instance: shulker-addon-matchmaking-metrics
app.kubernetes.io/component: shulker-addon-matchmaking
endpoints:
- targetPort: metrics
path: /metrics
interval: 60s
Loading

0 comments on commit 72cd61f

Please sign in to comment.