Skip to content

Commit

Permalink
base
Browse files Browse the repository at this point in the history
  • Loading branch information
templarfelix committed Apr 11, 2024
1 parent 812fc2e commit 720a5d4
Show file tree
Hide file tree
Showing 34 changed files with 404 additions and 561 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,23 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Docker meta
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: templarfelix/gameserver-operator
flavor: |
latest=true
-
name: Set up QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GitHub Container Registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
- name: Build and push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
Expand Down
73 changes: 64 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,91 @@
# gameserver-operator

Kubernetes operator for running LinuxGSM game servers.

# Thanks

<span style="background-color: #FFD700; color: black; padding: 2px 5px; border-radius: 5px;">LinuxGSM</span> - [Visit LinuxGSM Site](https://linuxgsm.com/)


## Description
The `GameServer-Operator` is a Kubernetes project designed to facilitate the deployment and management of LinuxGSM game servers in a Kubernetes environment. With this operator, users can easily scale their game servers, automate updates, and maintain desired configurations through Custom Resource Definitions (CRDs). This project aims to simplify the complexity of managing game servers by providing a robust and scalable solution for gaming communities and service providers.

The `GameServer-Operator` is a Kubernetes project designed to facilitate the deployment and management of LinuxGSM game
servers in a Kubernetes environment. With this operator, users can easily scale their game servers, automate updates,
and maintain desired configurations through Custom Resource Definitions (CRDs). This project aims to simplify the
complexity of managing game servers by providing a robust and scalable solution for gaming communities and service
providers.

## need help to deploy kubernetes clusters?

Navigate to the gameserver-operator GitHub project where the Pulumi script is located.
Navigate to the gameserver-operator GitHub project where the Pulumi script is located.

## Supported Games

The operator is capable of managing a variety of game servers supported by the LinuxGSM platform. Below is a list of popular games that are compatible, along with links to their specific configurations:
The operator is capable of managing a variety of game servers supported by the LinuxGSM platform. Below is a list of
popular games that are compatible, along with links to their specific configurations:

- **DayZ** - [Configurations](https://linuxgsm.com/lgsm/dayz/)
- **DayZ** - [Configurations](./docs/dayz.md)
- **AnotherGames ** - [Open Ticket](www.google.com.br)

For a complete list of supported games, visit the [LinuxGSM servers page](https://linuxgsm.com/servers/).

## Getting Started

## Install

Examples

### Kustomize

```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- github.com/templarfelix/gameserver-operator/config/default?ref=main
```
### ArgoCD
```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: gameserver-operator
namespace: argocd # This should be the namespace where Argo CD is installed
spec:
project: default # The Argo CD project, 'default' unless you've created others
source:
repoURL: 'https://github.com/templarfelix/gameserver-operator.git'
targetRevision: 'main'
path: 'config/default'
destination:
server: 'https://kubernetes.default.svc' # URL of the Kubernetes API server
namespace: 'default' # The namespace in Kubernetes where to deploy the application
syncPolicy:
automated: # Optional: enable automatic sync
selfHeal: true
prune: true # This will prune resources that are not in git anymore
```
## Build Local
### Prerequisites
- go version v1.20.0+
- docker version 17.03+.
- kubectl version v1.11.3+.
- Access to a Kubernetes v1.11.3+ cluster.
### To Deploy on the cluster
**Build and push your image to the location specified by `IMG`:**

```sh
make docker-build docker-push IMG=templarfelix/gameserver-operator:latest
```

**NOTE:** This image ought to be published in the personal registry you specified.
And it is required to have access to pull the image from the working environment.
**NOTE:** This image ought to be published in the personal registry you specified.
And it is required to have access to pull the image from the working environment.
Make sure you have the proper permission to the registry if the above commands don’t work.

**Install the CRDs into the cluster:**
Expand All @@ -47,8 +100,8 @@ make install
make deploy IMG=templarfelix/gameserver-operator:latest
```

> **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin
privileges or be logged in as admin.
> **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin
> privileges or be logged in as admin.

**Create instances of your solution**
You can apply the samples (examples) from the config/sample:
Expand All @@ -57,9 +110,10 @@ You can apply the samples (examples) from the config/sample:
kubectl apply -k config/samples/
```

>**NOTE**: Ensure that the samples has default values to test it out.
> **NOTE**: Ensure that the samples has default values to test it out.

### To Uninstall

**Delete the instances (CRs) from the cluster:**

```sh
Expand All @@ -79,6 +133,7 @@ make undeploy
```

## Contributing

// TODO(user): Add detailed information on how you would like others to contribute to this project

**NOTE:** Run `make help` for more information on all potential `make` targets
Expand Down
2 changes: 2 additions & 0 deletions _docs/games/dayz.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

- **DayZ** - [Configurations](https://linuxgsm.com/lgsm/dayz/)
2 changes: 2 additions & 0 deletions api/v1alpha1/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ type Base struct {
//+kubebuilder:default="10G"
Storage string `json:"storage,omitempty"`

LoadBalancerIP string `json:"loadBalancerIP,omitempty"`

Ports []corev1.ServicePort `json:"ports"`
}
2 changes: 2 additions & 0 deletions config/crd/bases/gameserver.templarfelix.com_dayzs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
image:
default: gameservermanagers/gameserver:dayz
type: string
loadBalancerIP:
type: string
ports:
items:
description: ServicePort contains information on service's port.
Expand Down
4 changes: 2 additions & 2 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/gameserver.templarfelix.com_dayzs.yaml
- bases/gameserver.templarfelix.com_projectzomboids.yaml
- bases/gameserver.templarfelix.com_dayzs.yaml
- bases/gameserver.templarfelix.com_projectzomboids.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patches:
Expand Down
24 changes: 12 additions & 12 deletions config/crd/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
nameReference:
- kind: Service
version: v1
fieldSpecs:
- kind: CustomResourceDefinition
- kind: Service
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/name
fieldSpecs:
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/name

namespace:
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/namespace
create: false
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/namespace
create: false

varReference:
- path: metadata/annotations
- path: metadata/annotations
14 changes: 7 additions & 7 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namePrefix: gameserver-operator-
# someName: someValue

resources:
- ../crd
- ../rbac
- ../manager
- ../crd
- ../rbac
- ../manager
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
#- ../webhook
Expand All @@ -27,10 +27,10 @@ resources:
#- ../prometheus

patches:
# Protect the /metrics endpoint by putting it behind auth.
# If you want your controller-manager to expose the /metrics
# endpoint w/o any authn/z, please comment the following line.
- path: manager_auth_proxy_patch.yaml
# Protect the /metrics endpoint by putting it behind auth.
# If you want your controller-manager to expose the /metrics
# endpoint w/o any authn/z, please comment the following line.
- path: manager_auth_proxy_patch.yaml

# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
Expand Down
56 changes: 28 additions & 28 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ spec:
template:
spec:
containers:
- name: kube-rbac-proxy
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- "ALL"
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8080/"
- "--logtostderr=true"
- "--v=0"
ports:
- containerPort: 8443
protocol: TCP
name: https
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 5m
memory: 64Mi
- name: manager
args:
- "--health-probe-bind-address=:8081"
- "--metrics-bind-address=127.0.0.1:8080"
- "--leader-elect"
- name: kube-rbac-proxy
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- "ALL"
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8080/"
- "--logtostderr=true"
- "--v=0"
ports:
- containerPort: 8443
protocol: TCP
name: https
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 5m
memory: 64Mi
- name: manager
args:
- "--health-probe-bind-address=:8081"
- "--metrics-bind-address=127.0.0.1:8080"
- "--leader-elect"
2 changes: 1 addition & 1 deletion config/default/manager_config_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ spec:
template:
spec:
containers:
- name: manager
- name: manager
66 changes: 33 additions & 33 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,38 @@ spec:
# seccompProfile:
# type: RuntimeDefault
containers:
- command:
- /manager
args:
- --leader-elect
image: controller:latest
name: manager
imagePullPolicy: Always
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- "ALL"
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
# TODO(user): Configure the resources accordingly based on the project requirements.
# More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 10m
memory: 64Mi
- command:
- /manager
args:
- --leader-elect
image: controller:latest
name: manager
imagePullPolicy: Always
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- "ALL"
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
# TODO(user): Configure the resources accordingly based on the project requirements.
# More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 10m
memory: 64Mi
serviceAccountName: controller-manager
terminationGracePeriodSeconds: 10
Loading

0 comments on commit 720a5d4

Please sign in to comment.