iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 17
0
自我挑戰組

從 RedHat OpenShift 社群版 OKD 看 Kubernetes系列 第 17

[卡位]Day 17 :yaml設定檔

  • 分享至 

  • xImage
  •  
$go env 

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jason/Library/Caches/go-build"
GOENV="/Users/jason/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
...
$operator-sdk new efk-operator --repo github.com/MengZn/efk-operator --dep-manager modules

INFO[0000] Creating new Go operator 'efk-operator'.
INFO[0000] Created go.mod
INFO[0000] Created tools.go
INFO[0000] Created cmd/manager/main.go
INFO[0000] Created build/Dockerfile
INFO[0000] Created build/bin/entrypoint
INFO[0000] Created build/bin/user_setup
INFO[0000] Created deploy/service_account.yaml
INFO[0000] Created deploy/role.yaml
INFO[0000] Created deploy/role_binding.yaml
INFO[0000] Created deploy/operator.yaml
INFO[0000] Created pkg/apis/apis.go
INFO[0000] Created pkg/controller/controller.go
INFO[0000] Created version/version.go
INFO[0000] Created .gitignore
INFO[0000] Validating project
go: finding github.com/operator-framework/operator-sdk master
go: finding github.com/prometheus/prometheus d3245f15022551c6fc8281766ea62db4d71e2747
INFO[0006] Project validation successful.
INFO[0006] Project creation complete.
$tree ~/go/src/github.com/efk-operator                       

/Users/jason/go/src/github.com/efk-operator
├── build
│   ├── Dockerfile
│   └── bin
│       ├── entrypoint
│       └── user_setup
├── cmd
│   └── manager
│       └── main.go
├── deploy
│   ├── operator.yaml
│   ├── role.yaml
│   ├── role_binding.yaml
│   └── service_account.yaml
├── go.mod
├── go.sum
├── pkg
│   ├── apis
│   │   └── apis.go
│   └── controller
│       └── controller.go
├── tools.go
└── version
    └── version.go

9 directories, 14 files
apiVersion: apps/v1
kind: Deployment
metadata:
  name: efk-operator
spec:
  replicas: 1
  selector:
    matchLabels:
      name: efk-operator
  template:
    metadata:
      labels:
        name: efk-operator
    spec:
      serviceAccountName: efk-operator
      containers:
        - name: efk-operator
          # Replace this with the built image name
          image: REPLACE_IMAGE
          command:
          - efk-operator
          imagePullPolicy: Always
          env:
            - name: WATCH_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: OPERATOR_NAME
              value: "efk-operator"

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: efk-operator
rules:
- apiGroups:
  - ""
  resources:
  - pods
  - services
  - services/finalizers
  - endpoints
  - persistentvolumeclaims
  - events
  - configmaps
  - secrets
  verbs:
  - "*"
- apiGroups:
  - apps
  resources:
  - deployments
  - daemonsets
  - replicasets
  - statefulsets
  verbs:
  - "*"
- apiGroups:
  - monitoring.coreos.com
  resources:
  - servicemonitors
  verbs:
  - "get"
  - "create"
- apiGroups:
  - apps
  resources:
  - deployments/finalizers
  resourceNames:
  - efk-operator
  verbs:
  - "update"
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - get
- apiGroups:
  - apps
  resources:
  - replicasets
  verbs:
  - get
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: efk-operator
subjects:
- kind: ServiceAccount
  name: efk-operator
roleRef:
  kind: Role
  name: efk-operator
  apiGroup: rbac.authorization.k8s.io
apiVersion: v1
kind: ServiceAccount
metadata:
  name: efk-operator

上一篇
[偷一下未來進度]Day 16 :單節點 OKD 安裝介紹
系列文
從 RedHat OpenShift 社群版 OKD 看 Kubernetes17
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言