Skip to content

Commit

Permalink
Add allocation policy CRD and schema definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
pooneh-m committed Apr 10, 2019
1 parent e6d9190 commit 806c46b
Show file tree
Hide file tree
Showing 4 changed files with 344 additions and 0 deletions.
95 changes: 95 additions & 0 deletions install/helm/agones/templates/crds/allocationpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright 2019 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

{{- if .Values.agones.crds.install }}

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
labels:
controller-tools.k8s.io: "1.0"
component: crd
app: {{ template "agones.name" . }}
chart: {{ template "agones.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
name: allocationpolicies.stable.agones.dev
spec:
group: stable.agones.dev
names:
kind: AllocationPolicy
plural: allocationpolicies
scope: Namespaced
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
connectionInfo:
properties:
allocationServiceSecret:
properties:
certificateAuthorityData:
type: string
serviceAccountToken:
type: string
required:
- certificateAuthorityData
- serviceAccountToken
type: object
apiServerEndpoint:
type: string
clusterName:
type: string
namespace:
type: string
required:
- clusterName
- apiServerEndpoint
- namespace
- allocationServiceSecret
type: object
priority:
format: int64
minimum: 0
type: integer
weight:
format: int64
minimum: 0
type: integer
required:
- priority
- weight
type: object
version: v1alpha1
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
{{- end }}
95 changes: 95 additions & 0 deletions install/yaml/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,101 @@ roleRef:
name: agones-sdk
---

---
# Source: agones/templates/crds/allocationpolicy.yaml
# Copyright 2019 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
labels:
controller-tools.k8s.io: "1.0"
component: crd
app: agones
chart: agones-0.10.0
release: agones-manual
heritage: Tiller
name: allocationpolicies.stable.agones.dev
spec:
group: stable.agones.dev
names:
kind: AllocationPolicy
plural: allocationpolicies
scope: Namespaced
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
properties:
connectionInfo:
properties:
allocationServiceSecret:
properties:
certificateAuthorityData:
type: string
serviceAccountToken:
type: string
required:
- certificateAuthorityData
- serviceAccountToken
type: object
apiServerEndpoint:
type: string
clusterName:
type: string
namespace:
type: string
required:
- clusterName
- apiServerEndpoint
- namespace
- allocationServiceSecret
type: object
priority:
format: int64
minimum: 0
type: integer
weight:
format: int64
minimum: 0
type: integer
required:
- priority
- weight
type: object
version: v1alpha1
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []

---
# Source: agones/templates/crds/fleet.yaml
# Copyright 2018 Google LLC All Rights Reserved.
Expand Down
61 changes: 61 additions & 0 deletions pkg/apis/stable/v1alpha1/allocationpolicy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2019 Google LLC All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// AllocationPolicySpec defines the desired state of AllocationPolicy
type AllocationPolicySpec struct {
// +kubebuilder:validation:Minimum=0
Priority int `json:"priority"`
// +kubebuilder:validation:Minimum=0
Weight int `json:"weight"`
ConnectionInfo ClusterConnectionInfo `json:"connectionInfo,omitempty"`
}

// ClusterConnectionInfo defines the connection information for a cluster
type ClusterConnectionInfo struct {
ClusterName string `json:"clusterName"`
APIServerEndpoint string `json:"apiServerEndpoint"`
Namespace string `json:"namespace"`
AllocationServiceSecret ClusterSecret `json:"allocationServiceSecret"`
}

// ClusterSecret defines the secret to connect to a cluster.
type ClusterSecret struct {
CertificateAuthorityData string `json:"certificateAuthorityData"`
ServiceAccountToken string `json:"serviceAccountToken"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// AllocationPolicy is the Schema for the allocationpolicies API
// +k8s:openapi-gen=true
type AllocationPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AllocationPolicySpec `json:"spec,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// AllocationPolicyList contains a list of AllocationPolicies
type AllocationPolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AllocationPolicy `json:"items"`
}
93 changes: 93 additions & 0 deletions pkg/apis/stable/v1alpha1/zz_generated.deepcopy.go

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

0 comments on commit 806c46b

Please sign in to comment.