-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
721 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# KubeSystemd | ||
|
||
**kube-systemd** is a controller to help manage systemd services on each Node in clusters. | ||
|
||
With clusters like minikube on hyberkit, which boot always from an ISO, | ||
**kube-systemd** could save configurations of systemd services and apply them after nodes started. | ||
|
||
**kube-systemd** introduces CRD Unit to save all configurations. | ||
|
||
```yaml | ||
type Unit struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec UnitSpec `json:"spec,omitempty"` | ||
Status UnitStatus `json:"status,omitempty"` | ||
} | ||
|
||
type UnitSpec struct { | ||
// Path defines the absolute path on the host of the unit. | ||
Path string `json:"path,omitempty"` | ||
|
||
// Definition specifies the unit definition. If set, it is written to the unit configuration which Path defines. | ||
// Or, the original unit on the host will be used. | ||
// +optional | ||
Definition string `json:"definition,omitempty"` | ||
|
||
// Config specifies config files and contents on the host with respect to the systemd unit. | ||
// The key is the absolute path of the configuration file. And, the value is the file content. | ||
// +optional | ||
Config map[string]string `json:"config,omitempty"` | ||
} | ||
``` | ||
|
||
## Install | ||
```shell script | ||
kubectl apply -f https://raw.githubusercontent.com/warm-metal/kube-systemd/master/config/samples/install.yaml | ||
``` | ||
|
||
## Demo | ||
|
||
We can create a unit to modify NTP server configuration in a minikube cluster to make sure the cluster clock is always | ||
synchronized to the NTP server. | ||
|
||
```yaml | ||
apiVersion: core.systemd.warmmetal.tech/v1 | ||
kind: Unit | ||
metadata: | ||
name: systemd-timesyncd.service | ||
spec: | ||
path: "/lib/systemd/system/systemd-timesyncd.service" | ||
config: | ||
"/etc/systemd/timesyncd.conf": | | ||
[Time] | ||
NTP=ntp1.aliyun.com | ||
``` | ||
After the unit executed, we could see that its status changed. | ||
That is, `status.execTimestamp` is updated to the time last executed. | ||
If errors raised, the `status.error` would be also updated. | ||
|
||
```yaml | ||
apiVersion: core.systemd.warmmetal.tech/v1 | ||
kind: Unit | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/last-applied-configuration: | | ||
{"apiVersion":"core.systemd.warmmetal.tech/v1","kind":"Unit","metadata":{"annotations":{},"name":"systemd-timesyncd.service"},"spec":{"config":{"/etc/systemd/timesyncd.conf":"[Time]\nNTP=ntp1.aliyun.com\n"},"path":"/lib/systemd/system/systemd-timesyncd.service"}} | ||
creationTimestamp: "2021-03-10T08:52:30Z" | ||
generation: 1 | ||
managedFields: | ||
- apiVersion: core.systemd.warmmetal.tech/v1 | ||
fieldsType: FieldsV1 | ||
fieldsV1: | ||
f:metadata: | ||
f:annotations: | ||
.: {} | ||
f:kubectl.kubernetes.io/last-applied-configuration: {} | ||
f:spec: | ||
.: {} | ||
f:config: | ||
.: {} | ||
f:/etc/systemd/timesyncd.conf: {} | ||
f:path: {} | ||
manager: kubectl-client-side-apply | ||
operation: Update | ||
time: "2021-03-10T08:52:30Z" | ||
- apiVersion: core.systemd.warmmetal.tech/v1 | ||
fieldsType: FieldsV1 | ||
fieldsV1: | ||
f:status: | ||
.: {} | ||
f:execTimestamp: {} | ||
manager: manager | ||
operation: Update | ||
time: "2021-03-10T08:52:30Z" | ||
name: systemd-timesyncd.service | ||
resourceVersion: "208241" | ||
uid: ad1d4311-b26b-4261-8551-f81f659fa2d3 | ||
spec: | ||
config: | ||
/etc/systemd/timesyncd.conf: | | ||
[Time] | ||
NTP=ntp1.aliyun.com | ||
path: /lib/systemd/system/systemd-timesyncd.service | ||
status: | ||
execTimestamp: "2021-03-10T09:08:46Z" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.4.1 | ||
creationTimestamp: null | ||
name: units.core.systemd.warmmetal.tech | ||
spec: | ||
group: core.systemd.warmmetal.tech | ||
names: | ||
kind: Unit | ||
listKind: UnitList | ||
plural: units | ||
singular: unit | ||
scope: Cluster | ||
versions: | ||
- name: v1 | ||
schema: | ||
openAPIV3Schema: | ||
description: Unit is the Schema for the units API | ||
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/sig-architecture/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/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
description: UnitSpec defines the desired state of Unit | ||
properties: | ||
config: | ||
additionalProperties: | ||
type: string | ||
description: Config specifies config files and contents on the host | ||
with respect to the systemd unit. The key is the absolute path of | ||
the configuration file. And, the value is the file content. | ||
type: object | ||
definition: | ||
description: Definition specifies the unit definition. If set, it | ||
is written to the unit configuration which Path defines. Or, the | ||
original unit on the host will be used. | ||
type: string | ||
path: | ||
description: Path defines the absolute path on the host of the unit. | ||
type: string | ||
type: object | ||
status: | ||
description: UnitStatus defines the observed state of Unit | ||
properties: | ||
error: | ||
description: Specify Errors on reconcile | ||
type: string | ||
execTimestamp: | ||
description: Timestamp of the last execution | ||
format: date-time | ||
type: string | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: [] | ||
storedVersions: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
kind: DaemonSet | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.