-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add logrotate & conf for etcd, mds, chunkserver.
- Loading branch information
1 parent
286296e
commit 9f9fb5c
Showing
6 changed files
with
101 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/logs/* { | ||
rotate 5 | ||
missingok | ||
compress | ||
copytruncate | ||
dateext | ||
createolddir | ||
olddir /logs/old | ||
size 10m | ||
notifempty | ||
} |
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,66 @@ | ||
package logrotate | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/pkg/errors" | ||
v1 "k8s.io/api/core/v1" | ||
kerrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/opencurve/curve-operator/pkg/daemon" | ||
) | ||
|
||
func CreateLogrotateConfigMap(c *daemon.Cluster) error { | ||
|
||
cm := &v1.ConfigMap{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "log-conf", | ||
Namespace: c.Namespace, | ||
}, | ||
Data: map[string]string{ | ||
"logrotate.conf": loadConfigFile("config/samples/logrotate.conf"), | ||
}, | ||
} | ||
|
||
err := c.OwnerInfo.SetControllerReference(cm) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = c.Context.Clientset.CoreV1().ConfigMaps(c.Namespace).Create(cm) | ||
if err != nil && !kerrors.IsAlreadyExists(err) { | ||
return errors.Wrapf(err, "failed to create %s configmap in namespace %s", cm.Name, c.Namespace) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func loadConfigFile(filepath string) string { | ||
|
||
content, err := os.ReadFile(filepath) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return string(content) | ||
} | ||
|
||
func MakeLogrotateContainer() v1.Container { | ||
container := v1.Container{ | ||
Name: "logrotate", | ||
Image: "linkyard/logrotate:1.0.0", | ||
VolumeMounts: []v1.VolumeMount{ | ||
{ | ||
Name: "log-volume", | ||
MountPath: "/logs", | ||
}, | ||
{ | ||
Name: "log-conf", | ||
MountPath: "/etc/logrotate.conf", | ||
SubPath: "logrotate.conf", | ||
}, | ||
}, | ||
} | ||
return container | ||
} |
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