Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit 8e51f88

Browse files
author
Yanqiang Miao
committed
Support unconfined apparmor
Signed-off-by: Yanqiang Miao <[email protected]>
1 parent a7471d7 commit 8e51f88

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pkg/server/container_create.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ func generateApparmorSpecOpts(apparmorProf string, privileged, apparmorEnabled b
784784
if !apparmorEnabled {
785785
// Should fail loudly if user try to specify apparmor profile
786786
// but we don't support it.
787-
if apparmorProf != "" {
787+
if apparmorProf != "" && apparmorProf != unconfinedProfile {
788788
return nil, fmt.Errorf("apparmor is not supported")
789789
}
790790
return nil, nil
@@ -793,7 +793,8 @@ func generateApparmorSpecOpts(apparmorProf string, privileged, apparmorEnabled b
793793
case runtimeDefault:
794794
// TODO (mikebrow): delete created apparmor default profile
795795
return apparmor.WithDefaultProfile(appArmorDefaultProfileName), nil
796-
// TODO(random-liu): Should support "unconfined" after kubernetes#52395 lands.
796+
case unconfinedProfile:
797+
return nil, nil
797798
case "":
798799
// Based on kubernetes#51746, default apparmor profile should be applied
799800
// for non-privileged container when apparmor is not specified.

pkg/server/container_create_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,17 @@ func TestGenerateApparmorSpecOpts(t *testing.T) {
805805
profile: "",
806806
privileged: true,
807807
},
808+
"should not return error if apparmor is unconfined when apparmor is not supported": {
809+
profile: unconfinedProfile,
810+
disable: true,
811+
},
812+
"should not apparmor when apparmor is unconfined": {
813+
profile: unconfinedProfile,
814+
},
815+
"should not apparmor when apparmor is unconfined and privileged is true": {
816+
profile: unconfinedProfile,
817+
privileged: true,
818+
},
808819
"should set default apparmor when apparmor is runtime/default": {
809820
profile: runtimeDefault,
810821
specOpts: apparmor.WithDefaultProfile(appArmorDefaultProfileName),

0 commit comments

Comments
 (0)