Skip to content

Commit

Permalink
fix: gamestatefulset --log-dir conflicts, issue TencentBlueKing#498
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperJim committed Jun 21, 2020
1 parent 3dc41f1 commit 796a215
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 107 deletions.
6 changes: 3 additions & 3 deletions bcs-k8s/bcs-gamestatefulset-operator/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## statefulsetplus-operator
## gamestatefulset-operator

gamestatefulset-operator是针对游戏gameserver实现增强版有状态部署operator。

Expand All @@ -7,7 +7,7 @@ gamestatefulset-operator是针对游戏gameserver实现增强版有状态部署o
* [done]本项目group重构可用
* [done]增加InplaceUpdate策略
* [todo]增加自动并行滚动更新
* [todo]扩展kubectl,支持kubectl statefulsetplus子命令
* [todo]扩展kubectl,支持kubectl gamestatefulset子命令
* [todo]支持HPA

### 特性
Expand Down Expand Up @@ -50,7 +50,7 @@ $ kubectl get pod -n test | grep web
web-0 1/1 Running 0 21s
```

#### 扩容statefulsetplus
#### 扩容gamestatefulset

```shell
$ kubectl scale --replicas=3 gamestatefulset/web -n test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
gamestatefulset "bcs-gamestatefulset-operator/pkg/controllers"
informers "bcs-gamestatefulset-operator/pkg/informers"

"github.com/golang/glog"
api "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/server"
Expand All @@ -37,6 +36,7 @@ import (
"k8s.io/client-go/tools/leaderelection"
"k8s.io/client-go/tools/leaderelection/resourcelock"
"k8s.io/client-go/tools/record"
"k8s.io/klog"
)

const (
Expand Down Expand Up @@ -143,18 +143,18 @@ func run() {
fmt.Printf("Rest Client Config: %v\n", cfg)

if err != nil {
glog.Fatalf("Error building kubeConfig: %s", err.Error())
klog.Fatalf("Error building kubeConfig: %s", err.Error())
}

kubeClient, err := kubernetes.NewForConfig(cfg)
if err != nil {
glog.Fatalf("Error building kubernetes clientset: %s", err.Error())
klog.Fatalf("Error building kubernetes clientset: %s", err.Error())
}
fmt.Println("Operator builds kube client success...")
tkexClient, err := clientset.NewForConfig(cfg)

if err != nil {
glog.Fatalf("Error building gamestatefulset clientset: %s", err.Error())
klog.Fatalf("Error building gamestatefulset clientset: %s", err.Error())
}
fmt.Println("Operator builds tkex client success...")
kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeClient, resyncPeriod(MinResyncPeriod)())
Expand All @@ -174,7 +174,7 @@ func run() {
fmt.Println("Operator starting tkex Informer factory success...")

if err = stsplusController.Run(1, stopCh); err != nil {
glog.Fatalf("Error running controller: %s", err.Error())
klog.Fatalf("Error running controller: %s", err.Error())
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: statefulsetplus-operator
description: A Helm chart for deployment statefulsetplus operator
name: gamestatefulset-operator
description: A Helm chart for deployment gamestatefulset operator

# A chart can be either an 'application' or a 'library' chart.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "statefulsetplus-operator.name" -}}
{{- define "gamestatefulset-operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

Expand All @@ -11,7 +11,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "statefulsetplus-operator.fullname" -}}
{{- define "gamestatefulset-operator.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
Expand All @@ -27,16 +27,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "statefulsetplus-operator.chart" -}}
{{- define "gamestatefulset-operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "statefulsetplus-operator.labels" -}}
helm.sh/chart: {{ include "statefulsetplus-operator.chart" . }}
{{ include "statefulsetplus-operator.selectorLabels" . }}
{{- define "gamestatefulset-operator.labels" -}}
helm.sh/chart: {{ include "gamestatefulset-operator.chart" . }}
{{ include "gamestatefulset-operator.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -46,17 +46,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "statefulsetplus-operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "statefulsetplus-operator.name" . }}
{{- define "gamestatefulset-operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "gamestatefulset-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "statefulsetplus-operator.serviceAccountName" -}}
{{- define "gamestatefulset-operator.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "statefulsetplus-operator.fullname" .) .Values.serviceAccount.name }}
{{ default (include "gamestatefulset-operator.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "statefulsetplus-operator.fullname" . }}
name: {{ include "gamestatefulset-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "statefulsetplus-operator.labels" . | nindent 4 }}
{{- include "gamestatefulset-operator.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "statefulsetplus-operator.selectorLabels" . | nindent 6 }}
{{- include "gamestatefulset-operator.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "statefulsetplus-operator.selectorLabels" . | nindent 8 }}
{{- include "gamestatefulset-operator.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "statefulsetplus-operator.serviceAccountName" . }}
serviceAccountName: {{ include "gamestatefulset-operator.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "statefulsetplus-operator.serviceAccountName" . }}
name: {{ include "gamestatefulset-operator.serviceAccountName" . }}
labels:
{{- include "statefulsetplus-operator.labels" . | nindent 4 }}
{{- include "gamestatefulset-operator.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Default values for statefulsetplus-operator.
# Default values for gamestatefulset-operator.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: statefulsetplus-operator
repository: gamestatefulset-operator
pullPolicy: IfNotPresent

imagePullSecrets: []
Expand All @@ -19,7 +19,7 @@ serviceAccount:
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: statefulsetplus-operator
name: gamestatefulset-operator

resources:
# We usually recommend not to specify default resources and to leave this as a conscious
Expand Down
3 changes: 1 addition & 2 deletions bcs-k8s/bcs-gamestatefulset-operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ require (
github.com/go-openapi/jsonreference v0.19.3 // indirect
github.com/go-openapi/spec v0.19.3 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
Expand Down Expand Up @@ -59,7 +58,7 @@ require (
k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93
k8s.io/apiserver v0.0.0-20181213151703-3ccfe8365421
k8s.io/client-go v0.0.0-20181213151034-8d9ed539ba31
k8s.io/klog v1.0.0 // indirect
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20181109181836-c59034cc13d5 // indirect
k8s.io/kubernetes v1.13.1
k8s.io/utils v0.0.0-20200124190032-861946025e34 // indirect
Expand Down
3 changes: 0 additions & 3 deletions bcs-k8s/bcs-gamestatefulset-operator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,10 @@ k8s.io/apiextensions-apiserver v0.0.0-20181213153335-0fe22c71c476 h1:Ws9zfxsgV19
k8s.io/apiextensions-apiserver v0.0.0-20181213153335-0fe22c71c476/go.mod h1:IxkesAMoaCRoLrPJdZNZUQp9NfZnzqaVzLhb2VEQzXE=
k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93 h1:tT6oQBi0qwLbbZSfDkdIsb23EwaLY85hoAV4SpXfdao=
k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
k8s.io/apimachinery v0.18.4 h1:ST2beySjhqwJoIFk6p7Hp5v5O0hYY6Gngq/gUYXTPIA=
k8s.io/apiserver v0.0.0-20181213151703-3ccfe8365421 h1:NyOpnIh+7SLvC05NGCIXF9c4KhnkTZQE2SxF+m9otww=
k8s.io/apiserver v0.0.0-20181213151703-3ccfe8365421/go.mod h1:6bqaTSOSJavUIXUtfaR9Os9JtTCm8ZqH2SUl2S60C4w=
k8s.io/client-go v0.0.0-20181213151034-8d9ed539ba31 h1:OH3z6khCtxnJBAc0C5CMYWLl1CoK5R5fngX7wrwdN5c=
k8s.io/client-go v0.0.0-20181213151034-8d9ed539ba31/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
k8s.io/client-go v1.5.1 h1:XaX/lo2/u3/pmFau8HN+sB5C/b4dc4Dmm2eXjBH4p1E=
k8s.io/client-go v11.0.0+incompatible h1:LBbX2+lOwY9flffWlJM7f1Ct8V2SRNiMRDFeiwnJo9o=
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type GameStatefulSet struct {
Status GameStatefulSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}

// PodManagementPolicyType defines the policy for creating pods under a statefulsetplus.
// PodManagementPolicyType defines the policy for creating pods under a gamestatefulset.
type PodManagementPolicyType string

const (
Expand Down
Loading

0 comments on commit 796a215

Please sign in to comment.