Skip to content

Commit

Permalink
Some improve on README.md&deploy.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
WanLinghao committed Aug 27, 2019
1 parent 78f8c16 commit e27493c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@

----

## Motivation and Goals

As we know, bugs are inevitable in software development, some bugs could be solved by investigating app logs, but some serious bugs like deep null point exception is very hard to debug without core files.However, Kubernetes has no mechanism to manage core files when job inside pods crashed.

This feature mainly collects, stores, distributes core files which generated by the apps inside pods. It supports any filesystem storage as backend storage, and it embeds the K8s' own authorization mechanism like RBAC to control tenant authorities. Tenants could download those core files they want like they are using any other original K8s resources.

## Design

### Backend storage

The bakcend storage is an dependent filesystem storage to store core files. This storage could be either ceph filesystem storage,
The bakcend storage is an independent filesystem storage to store core files. This storage could be either ceph filesystem storage,
nfs storage or any other filesystem storage.
For test purpose, you can also use local host[https://kubernetes.io/docs/concepts/storage/volumes/#hostpath] storage to store core files.

Expand All @@ -33,6 +39,45 @@ The core file generation part generates core files when job inside containers cr
An aggregation api layer will register a self-defined API called `coredump.fujitsu.com`. This api is a bridge between backend storage
and users. User could download core files by this api. Admin can control users' access to core files by native way like RBAC, ABAC.

### Warning

The `core_pattern` would be modified to let our components handle core dump events.

The k8s cluster must boot with `allow-privileged` option enabled.

## Deployment

See [INSTALL.md](INSTALL.md) for details about how to deploy k8s-audit-collector
### From script

We have a [auto deploy script](deploy/deploy.sh) which could generate a yaml file. Then run `kubectl create -f [yaml file]` deploy it in your cluster.
This script uses local '/tmp' directory as backend storage to store core files and etcd data.
It also generates certificates automatically to let [aggregation api](https://kubernetes.io/docs/tasks/access-kubernetes-api/setup-extension-api-server/) use.
You could replace either backend storage or certificates with your own one.

### From source code

TBD

### Test

After deploying all the components successfully, you could test the function is working by [test script](test/run-test.sh)


## Download core files

### From exist pod
Suppose users want to download core files from a container called `test-container` in exist pod `default/test-pod`, they should do like:

```
cat test/coredumpendpoint_template.yaml |sed "s/__NAMESPACE__/default/g" | sed "s/__NAME__/test-pod/g"| kubectl create -f -
kubectl get --raw=/apis/coredump.fujitsu.com/v1alpha1/namespaces/default/coredumpendpoints/test-pod/dump?container=test-container>>coredump.tar.gz
```

### From non-exist pod
When users want to download core files from a pod that has been deleted, pod's uid must be provided.
Suppose users want to download core files from a container called `test-container` in exist pod `default/test-pod`, and the uid of that pod is `1234-5678`, they should do like:

```
cat test/coredumpendpoint_template.yaml |sed "s/__NAMESPACE__/default/g" | sed "s/__NAME__/test-pod/g"| sed "s/__UID__/1234-5678/g"|kubectl create -f -
kubectl get --raw=/apis/coredump.fujitsu.com/v1alpha1/namespaces/default/coredumpendpoints/test-pod/dump?container=test-container>>coredump.tar.gz
```
2 changes: 1 addition & 1 deletion deploy/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ openssl req -x509 -newkey rsa:2048 -keyout $dir/apiserver_ca.key -out $dir/apis
openssl req -out $dir/apiserver.csr -new -newkey rsa:2048 -nodes -keyout $dir/apiserver.key -subj /C=un/ST=st/L=l/O=o/OU=ou/CN=$name.$namespace.svc
openssl x509 -req -days 365 -in $dir/apiserver.csr -CA $dir/apiserver_ca.crt -CAkey $dir/apiserver_ca.key -CAcreateserial -out $dir/apiserver.crt

cp ./apiserver_template.yaml $dir
cp ./apiserver_template.yaml $dir/apiserver.yaml

api_svc_pem=$(extract_pem $dir/apiserver_ca.crt)
echo $api_svc_pem
Expand Down
2 changes: 1 addition & 1 deletion test/coredumpendpoint_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: CoredumpEndpoint
metadata:
namespace: __NAMESPACE__
name: __NAME__
spec:
spec: __UID__
1 change: 1 addition & 0 deletions test/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ test_create_coredumpendpoint(){
cp $COREDUMP_TEMPLATE $yaml_file
sed -i "s/__NAMESPACE__/${namespace}/g" $yaml_file
sed -i "s/__NAME__/${pod}/g" $yaml_file
sed -i "s/__UID__//g" $yaml_file
create_via_file $yaml_file
}

Expand Down

0 comments on commit e27493c

Please sign in to comment.