dashanji commented on code in PR #66:
URL: https://github.com/apache/skywalking-swck/pull/66#discussion_r936917723


##########
Makefile:
##########
@@ -54,13 +54,18 @@ clean: ## Clean project
 ##@ End to End Test
 
 .PHONY:e2e-test
-e2e-test: e2e-oap-ui-agent e2e-oap-ui-agent-storage-internal 
e2e-oap-agent-adapter-hpa e2e-oap-ui-agent-satellite 
e2e-oap-agent-satellite-adapter-hpa 
e2e-oap-ui-agent-oapserverconfig-oapserverdynamicconfig ## Run End to End tests.
+e2e-test: e2e-oap-ui-agent e2e-oap-ui-agent-crd 
e2e-oap-ui-agent-storage-internal e2e-oap-agent-adapter-hpa 
e2e-oap-ui-agent-satellite e2e-oap-agent-satellite-adapter-hpa 
e2e-oap-ui-agent-oapserverconfig-oapserverdynamicconfig ## Run End to End tests.
 
 .PHONY:e2e-oap-ui-agent
 e2e-oap-ui-agent: e2e ## Run oap+ui+agent test
        @echo "Run oap+ui+agent e2e..."
        $(E2E) run -c test/e2e/oap-ui-agent/e2e.yaml
 
+.PHONY:e2e-oap-ui-agent-crd

Review Comment:
   How about using `e2e-oap-ui-swagent` ?



##########
docs/examples/java-agent-injector-usage.md:
##########
@@ -37,12 +33,27 @@ spec:
         image: ghcr.io/apache/skywalking-swck-spring-demo:v0.0.1
         command: ["java"]
         args: ["-jar","/app.jar"]
-   
 ```
 
-Get injected resources as below:
+## Enable Injection for Namespace and Deployments/StatefulSets.
+
+At first, set the injection label in your namespace as below.
+
+```shell
+kubectl label namespace default(your namespace) swck-injection=enabled
+```
+
+Secondly, set the injection label for your target Deployment/StatefulSet.
 
+```shell
+kubectl -n default(your namespace) patch deployment demo1 --patch '{"spec": 
{"template": {"metadata": {"labels": {"swck-java-agent-injected": "true"}}}}}'
 ```
+
+Then the pods create by the Deployments/StatefulSets would be recreated with 
agent injected.
+
+The injected pods would like this:

Review Comment:
   would be



##########
golangci.yml:
##########
@@ -18,10 +18,9 @@ linters:
     - deadcode
     - errcheck
     - goconst
-    - golint
+    - revive

Review Comment:
   Will it cause errors if not modified?



##########
docs/examples/java-agent-injector-usage.md:
##########
@@ -185,112 +218,59 @@ spec:
     - java
     env:
     - name: JAVA_TOOL_OPTIONS
-      value: -javaagent:/skytest/agent/skywalking-agent.jar
+      value: -javaagent:/sky/agent/skywalking-agent.jar
+    - name: SW_LOGGING_LEVEL
+      value: "DEBUG"
     image: ghcr.io/apache/skywalking-swck-spring-demo:v0.0.1
-    name: demo2
-    - mountPath: /skytest/agent
-      name: sky-agent
-    - mountPath: /skytest/agent/config
-      name: java-agent-configmap-volume
+    name: demo1
+    - mountPath: /sky/agent
+      name: sky-agent-test-001
+    - mountPath: /sky/agent/config
+      name: java-agent-configmap-test-001-volume
   initContainers:
   - args:
     - -c
-    - mkdir -p /skytest/agent && cp -r /skywalking/agent/* /skytest/agent
+    - mkdir -p /sky/agent && cp -r /skywalking/agent/* /sky/agent
     command:
     - sh
-    image: apache/skywalking-java-agent:8.5.0-jdk8
-    name: test-inject-agent
+    image: apache/skywalking-java-agent:8.9.0-java8
+    name: swagent-001
     volumeMounts:
-    - mountPath: /skytest/agent
-      name: sky-agent
+    - mountPath: /sky/agent
+      name: sky-agent-test-001
   volumes:
   - emptyDir: {}
-    name: sky-agent
+    name: sky-agent-test-001
   - configMap:
-      name: newconfigmap
-    name: java-agent-configmap-volume
-```
-
-```shell
-$ kubectl get configmap newconfigmap -n default
-NAME           DATA   AGE
-newconfigmap   1      2m29s
-```
-
-Then you can get the final agent configuration and the pod as below.
-
-```shell
-$ kubectl get javaagent
-NAME                  PODSELECTOR   SERVICENAME            BACKENDSERVICE
-app-demo2-javaagent   app=demo2     Your_ApplicationName   127.0.0.1:11800
-$ kubectl get pod -l app=demo2(the podSelector)
-NAME                     READY   STATUS    RESTARTS   AGE
-demo2-74b65f98b9-k5wvd   1/1     Running   0          3m28s
-```
-
-Get the javaagent's yaml for more datails.
-
-```shell
-$ kubectl get javaagent app-demo2-javaagent -oyaml
-apiVersion: operator.skywalking.apache.org/v1alpha1
-kind: JavaAgent
-metadata:
-  creationTimestamp: "2021-10-15T05:10:16Z"
-  generation: 1
-  name: app-demo2-javaagent
-  namespace: default
-  ownerReferences:
-  - apiVersion: apps/v1
-    blockOwnerDeletion: true
-    controller: true
-    kind: ReplicaSet
-    name: demo2-74b65f98b9
-    uid: cbc2c680-4f84-469a-bb43-fc48161d6958
-  resourceVersion: "458626"
-  selfLink: 
/apis/operator.skywalking.apache.org/v1alpha1/namespaces/default/javaagents/app-demo2-javaagent
-  uid: 7c59aab7-30fc-4122-8b39-4cba2d1711b5
-spec:
-  agentConfiguration:
-    agent.service_name: Your_ApplicationName
-    collector.backend_service: 127.0.0.1:11800
-  backendService: 127.0.0.1:11800
-  podSelector: app=demo2
-  serviceName: Your_ApplicationName
-status:
-  creationTime: "2021-10-15T05:10:16Z"
-  expectedInjectiedNum: 1
-  lastUpdateTime: "2021-10-15T05:10:18Z"
-  realInjectedNum: 1
+      name: skywalking-swck-java-agent-configmap
+    name: java-agent-configmap-test-001-volume
 ```
 
-#### Use annotation to set the coverage strategy and override the agent 
configuration
-
-At first, set the injection label in your namespace as below.
-
-```shell
-kubectl label namespace default(your namespace) swck-injection=enabled
-```
+## Use annotation to override sidecar configuration
 
-Then add `swck-java-agent-injected: "true"` in the labels of yaml file and 
[agent 
configuration](../java-agent-injector.md#use-annotations-to-overlay-default-agent-configuration)
 and [sidecar configuration](../java-agent-injector.md#configure-sidecar) to 
annotations as below.
+Suppose that injection label had been set for Namespace and 
Deployments/StatefulSets as [previous 
said](java-agent-injector-usage-draft.md#enable-injection-for-namespace-and-deploymentsstatefulsets).

Review Comment:
   The same as before.



##########
docs/examples/java-agent-injector-usage.md:
##########
@@ -130,52 +141,74 @@ status:
   realInjectedNum: 1
 ```
 
-## Use annotation to override sidecar configuration
+## Use SwAgent CR to setup override default configuration
 
-At first, set the injection label in your namespace as below.
+Suppose that injection label had been set for Namespace and 
Deployments/StatefulSets as [previous 
said](java-agent-injector-usage-draft.md#enable-injection-for-namespace-and-deploymentsstatefulsets).
+
+Apply SwAgent CR with correct label selector and container matcher:
+
+```yaml
+# SwAgent.yaml
+apiVersion: operator.skywalking.apache.org/v1alpha1
+kind: SwAgent
+metadata:
+  name: swagent-001
+  namespace: skywalking-system
+spec:
+  # container matcher, regular expression is supported
+  containerMatcher: '.*'
+  # label selector
+  selector:
+    app: demo1
+  javaSidecar:
+    # init container name
+    name: swagent-001
+    # init container image
+    image: apache/skywalking-java-agent:8.9.0-java8
+    # envs to be appended to target containers
+    env:
+      - name: SW_LOGGING_LEVEL
+        value: "DEBUG"
+  # share volume
+  sharedVolume:
+    name: "sky-agent-test-001"
+    mountPath: "/sky/agent"
+  # default configmap
+  swConfigMapVolume:
+    name: "java-agent-configmap-test-001-volume"
+    configMapName: "skywalking-swck-java-agent-configmap"
+    configMapMountPath: "/sky/agent/config"
+
+```
 
 ```shell
-kubectl label namespace default(your namespace) swck-injection=enabled
+kubectl -n skywalking-system apply swagent.yaml
 ```
 
-Then add `swck-java-agent-injected: "true"` in the labels of yaml file and add 
the [sidecar configuration](../java-agent-injector.md#configure-sidecar) to the 
annotations as below.
+You can also get SwAgent CR by:
 
+```shell
+kubectl -n skywalking-system get SwAgent
 ```
-apiVersion: apps/v1
-kind: Deployment
-metadata:
-  name: demo2
-  namespace: default
-spec:
-  selector:
-    matchLabels:
-      app: demo2
-  template:
-    metadata:
-      labels:
-        swck-java-agent-injected: "true"
-        app: demo2
-      annotations:
-        sidecar.skywalking.apache.org/initcontainer.Name: "test-inject-agent"
-        sidecar.skywalking.apache.org/initcontainer.Image: 
"apache/skywalking-java-agent:8.5.0-jdk8"
-        sidecar.skywalking.apache.org/initcontainer.Command: "sh"
-        sidecar.skywalking.apache.org/initcontainer.args.Option: "-c"
-        sidecar.skywalking.apache.org/initcontainer.args.Command: "mkdir -p 
/skytest/agent && cp -r /skywalking/agent/* /skytest/agent"
-        sidecar.skywalking.apache.org/sidecarVolumeMount.MountPath: 
"/skytest/agent"
-        sidecar.skywalking.apache.org/configmapVolumeMount.MountPath: 
"/skytest/agent/config"
-        sidecar.skywalking.apache.org/configmapVolume.ConfigMap.Name: 
"newconfigmap"
-        sidecar.skywalking.apache.org/env.Value: 
"-javaagent:/skytest/agent/skywalking-agent.jar"
-    spec:
-      containers:
-      - name: demo2
-        image: ghcr.io/apache/skywalking-swck-spring-demo:v0.0.1
-        command: ["java"]
-        args: ["-jar","/app.jar"]
+
+Now the pods is still the old one, because pods could not load the SwAgent 
config automatically.
+
+To load swagent config we applied just now, delete the pods which create by 
the Deployments/StatefulSet.

Review Comment:
    create -> created



##########
docs/examples/java-agent-injector-usage.md:
##########
@@ -130,52 +141,74 @@ status:
   realInjectedNum: 1
 ```
 
-## Use annotation to override sidecar configuration
+## Use SwAgent CR to setup override default configuration
 
-At first, set the injection label in your namespace as below.
+Suppose that injection label had been set for Namespace and 
Deployments/StatefulSets as [previous 
said](java-agent-injector-usage-draft.md#enable-injection-for-namespace-and-deploymentsstatefulsets).

Review Comment:
   Is the link valid? I can't find the file 
`java-agent-injector-usage-draft.md`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to