Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: remove hardcoded path to kubeconfig file #96

Merged

Conversation

arnaud-tincelin
Copy link
Collaborator

No description provided.

@arnaud-tincelin arnaud-tincelin force-pushed the fix/remove-hardcoded-kubeconfig branch 2 times, most recently from 52d1cd4 to dc918a1 Compare August 7, 2021 14:06
@Tatsinnit Tatsinnit requested review from Tatsinnit and JunSun17 August 8, 2021 05:45
@Tatsinnit Tatsinnit linked an issue Aug 8, 2021 that may be closed by this pull request
Copy link
Contributor

@safeermohammed safeermohammed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@arnaud-tincelin arnaud-tincelin force-pushed the fix/remove-hardcoded-kubeconfig branch 2 times, most recently from 757f41d to 9211b6a Compare August 9, 2021 22:11
@Tatsinnit Tatsinnit requested a review from sophsoph321 August 10, 2021 04:06
Copy link
Member

@Tatsinnit Tatsinnit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Thank you so much for this 🙏 +1 for This PR as it simplifies the use of containerName and various things it unblocks in future. Issue was there because from day-1 the APIServerName was used as containerName : detailed in #99

This will sit nicely and fix any of the ARC scenario as well.

Few things to stock take please:

I do know that for any breaking changes we just need plan and some part of above comment is circling around that preparation. (we need to give enough time for other tools to adapt these changes)

  • Important and might be worth a discussion : I am happy to merge once we catered some of thee recommendations and keep these changes as release v0.5 or something, but we just need to think of scenario if there is something we need to fix for any other consuming tool where we will end with this change which needs work at that consuming tool. to: @rzhang628 , @qpetraroia , @palma21 , @sophsoph321 - as fyi and to please stock take and we can start the work in the consuming tool on the side to avoid any convoluted situation. @JunSun17 - if you have any opinions. Thanks you all.

Rest of PR looks great, but I think a plan is key for all including PMs 👍 thanks heaps

@@ -57,12 +50,6 @@ func (collector *NetworkOutboundCollector) Collect() error {
URL: "kubernetes.default.svc.cluster.local:443",
},
)
outboundTypes = append(outboundTypes,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 Can we not make this removal part of this PR please, we don't know why it existed, @rzhang628 , @qpetraroia or @palma21 - If anyone of you have any insight for this please? removing this means taking small functionality out of periscope and since its in Azure org I would prefer wider eyes on this please. Thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what should we set instead?


containerName := strings.Replace(APIServerFQDN, ".", "-", -1)
containerLen := strings.Index(containerName, "-hcp-")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 This logic needs to be extracted in some kind of git issue, (cc: @sophsoph321 - because az-cli will now do this before supplying the container name as APIServerName ) also fyi: @rzhang628 and @qpetraroia - vscode also need similar tracking workitem in its queue and I can work on that change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this needs to be documented in the release 0.5. Not sure what would be the benefit of an issue

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, so the reason we need this is because periscope as a tool from beginning has working contract with “az-cli” via kollect command and latter vscode started using so anything effecting long term to these tools or any change of contract needs to be highlighted.

with tracking workitem we need to inform those consuming tools: (give enough information for this change)

refrence:

thanks 🙏

Copy link
Collaborator Author

@arnaud-tincelin arnaud-tincelin Aug 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these 2 paragraphs have to be removed from our README:

  • first one: we are not developping aks-periscope only for vscode & az cli; some others might use it and anyway noone can change this file unless a PR is approved. + we already documented this file as deprecated
  • 2nd one: the detail of how to use an extension of az-cli shall be in the extension repo. We are not going to watch the extension repo so that we can align our README. However we can indicate that az-cli can be used to deploy aks-periscope and add a link to our repo to the extension

see #102. We should add a PR to az cli extension with the README about kollect command

containerLen := strings.Index(containerName, "-hcp-")
if containerLen == -1 {
containerLen = maxContainerNameLength
if accountName == "" || sasKey == "" || containerName == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 Please add check for containerName length. 3 to 63 is the min and max - otherwise it will fail and in that case how will we handle that scenario? https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata#container-names

There are bunch of stuff removed and will sit under consuming tool which looks cool.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm sure but in the same logic we could also check the accountname format, the saskey format etc ... I'd rather not do checks here. Anyway the user will eventually have an error from the service

Copy link
Member

@Tatsinnit Tatsinnit Aug 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡This logic (containerName specific) was already pre-existing in this tool, if we keep that length as it is it and do not remove we take pain from other consuming tool managing their own version of this?

@@ -132,28 +131,6 @@ func GetHostName() (string, error) {
return hostName.HostName, nil
}

// GetAPIServerFQDN gets the API Server FQDN from the kubeconfig file
func GetAPIServerFQDN() (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Same as above comment, that we could move this to netwrokbound_collector.go but completely removing which include taking small chunk of log out of the logs which gets dumb - looks ok to my eyes but need folks like @JunSun17 or @rzhang628, @qpetraroia to verify what are the key reasons it was there at first place.

@@ -1,50 +0,0 @@
# Deploy with Kustomize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Can we please keep this as a document, will be good to update the instructions for newbieusers who want to see how kustomize file will fit together and how they can consume this in their tool or their purpose. Thanks

cc: @rzhang628 and @qpetraroia

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation is in the example file we added. This brings no value so we should remove it

@Tatsinnit
Copy link
Member

Tatsinnit commented Aug 11, 2021

Thanks Arnaud, @sophsoph321 can you please test this as a test image? cc: @safeermohammed Thank you.

  • can you publish your local image or you need hand for that please? (please don't hesitate) thank you

@arnaud-tincelin arnaud-tincelin force-pushed the fix/remove-hardcoded-kubeconfig branch from 5959c22 to fbe1bf0 Compare August 11, 2021 22:06
@arnaud-tincelin
Copy link
Collaborator Author

Thanks Arnaud, @sophsoph321 can you please test this as a test image? cc: @safeermohammed Thank you.

  • can you publish your local image or you need hand for that please? (Don't hesitate?) thank you

Feel free to use ghcr.io/arnaud-tincelin/aks-periscope:0.5

@sophsoph321
Copy link
Collaborator

Thank you @arnaud-tincelin for helping us get unblocked. I have tested using the image you provided on the different distros for our MVP and those changes look good.
If we can add the env variable AZURE_BLOB_CONTAINER_NAME in the aks-periscope.yaml file, we should be good to merge this PR.

@Tatsinnit
Copy link
Member

Tatsinnit commented Aug 12, 2021

Thank you @arnaud-tincelin for helping us get unblocked. I have tested using the image you provided on the different distros for our MVP and those changes look good.
If we can add the env variable AZURE_BLOB_CONTAINER_NAME in the aks-periscope.yaml file, we should be good to merge this PR.

Thanks @sophsoph321 for checking, that is good that image is good for your scenarios. - To expedite this, I would recommend - share your *.yaml you are using and we could keep it under examples folder under deployment which will be only short term solution until you start to do whole kubectl kustomize at your functionality level. Just as a thought: We cannot change aks-periscope.yaml because it is used by because it is consumed az-cli and vscode - Please read this tracking item - #99

And, If I may suggest, lets add a sample way how to use kubectl kustomize command, and to build it with storage_details (Which is one of the key sceanrio).

Thanks.

@sophsoph321
Copy link
Collaborator

Thanks @sophsoph321 for checking, that is good that image is good for your scenarios. - To expedite this, I would recommend - share your *.yaml you are using and we could keep it under examples folder under deployment which will be only short term solution until you start to do whole kubectl kustomize at your functionality level. Just as a thought: We cannot change aks-periscope.yaml because it is used by because it is consumed az-cli and vscode - Please read this tracking item - #99

And, If I may suggest, lets add a sample way how to use kubectl kustomize command, and to build it with storage_details.

Thanks.

@arnaud-tincelin Spoke to @Tatsinnit offline. We used the "kubectl kustomize" to construct a single yaml file for the kustomize template. The aks-periscope pods have a ContainerCreationError with the following error message: "Error: secret "azureblob-secret" not found".
For the time being, I used this yaml file to test your code changes, the contents of this file can reside in the examples directory for kustomize (git will not allow me to attach yaml files, so it's in txt format)
azure-k8s-periscope.txt

@arnaud-tincelin
Copy link
Collaborator Author

arnaud-tincelin commented Aug 12, 2021

Hi @sophsoph321 apologies, there were 2 mistakes in the example file:

  • namespace was not specified so the secret was not created (add namespace: aks-periscope)
  • value of the secret should not be base64 encoded (value of AZURE_BLOB_SAS_KEY)

Let me know if it works better this way

Here is the fixed kustomization.yaml file. You may deploy it with kubectl apply <(kustomize build):

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- https://github.com/Azure/aks-periscope/deployment//

namespace: aks-periscope

secretGenerator:
- name: azureblob-secret
  literals:
  - AZURE_BLOB_SAS_KEY=?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2021-08-15T16:02:03Z&st=2021-08-10T08:02:03Z&spr=https&sig=REDACTED
       
patches:
- target:
    group: apps
    kind: DaemonSet
    name: aks-periscope
    version: v1
  patch: |-
    - op: add
      path: '/spec/template/spec/containers/0/env'
      value:
        - name: AZURE_BLOB_ACCOUNT_NAME
          value: mystorageaccount
        - name: AZURE_BLOB_CONTAINER_NAME
          value: mycontainer
- target:
    group: apps
    kind: DaemonSet
    name: aks-periscope
    version: v1
  patch: |-
    - op: add
      path: '/spec/template/spec/containers/0/envFrom/-'
      value:
        secretRef:
          name: azureblob-secret

images:
  - name: aksrepos.azurecr.io/staging/aks-periscope
    newName: ghcr.io/arnaud-tincelin/aks-periscope
    newTag: '0.5'

@arnaud-tincelin arnaud-tincelin force-pushed the fix/remove-hardcoded-kubeconfig branch from fbe1bf0 to d41386f Compare August 12, 2021 08:27
@arnaud-tincelin arnaud-tincelin force-pushed the fix/remove-hardcoded-kubeconfig branch from d41386f to 463e94b Compare August 12, 2021 09:16
Copy link
Collaborator

@sophsoph321 sophsoph321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving this PR. I added a workaround on my side for the CLI changes have tested regarding the AZURE_BLOB_CONTAINER_NAME field and the changes look good. So adding the yaml file I shared last night to the example folder is completely optional.

@sophsoph321
Copy link
Collaborator

Hi @sophsoph321 apologies, there were 2 mistakes in the example file:

  • namespace was not specified so the secret was not created (add namespace: aks-periscope)
  • value of the secret should not be base64 encoded (value of AZURE_BLOB_SAS_KEY)

Let me know if it works better this way

Here is the fixed kustomization.yaml file. You may deploy it with kubectl apply <(kustomize build):

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- https://github.com/Azure/aks-periscope/deployment//

namespace: aks-periscope

secretGenerator:
- name: azureblob-secret
  literals:
  - AZURE_BLOB_SAS_KEY=?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2021-08-15T16:02:03Z&st=2021-08-10T08:02:03Z&spr=https&sig=REDACTED
       
patches:
- target:
    group: apps
    kind: DaemonSet
    name: aks-periscope
    version: v1
  patch: |-
    - op: add
      path: '/spec/template/spec/containers/0/env'
      value:
        - name: AZURE_BLOB_ACCOUNT_NAME
          value: mystorageaccount
        - name: AZURE_BLOB_CONTAINER_NAME
          value: mycontainer
- target:
    group: apps
    kind: DaemonSet
    name: aks-periscope
    version: v1
  patch: |-
    - op: add
      path: '/spec/template/spec/containers/0/envFrom/-'
      value:
        secretRef:
          name: azureblob-secret

images:
  - name: aksrepos.azurecr.io/staging/aks-periscope
    newName: ghcr.io/arnaud-tincelin/aks-periscope
    newTag: '0.5'

@arnaud-tincelin thanks for the fix. I have tested these new fixes and generated a single yaml file based on your changes and it looks good.

Copy link
Member

@Tatsinnit Tatsinnit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Since @sophsoph321 approves it with scenarios which ARC needs to fit in, moving forward keeping this issue in mind: #99 - we can approve this and move forward.

Thanks you so much guys 🙏☕️❤️

@Tatsinnit Tatsinnit added the breaking change 🚨 This label indicates that the work item contains breaking change. label Aug 12, 2021
@Tatsinnit Tatsinnit merged commit 41d83b0 into Azure:master Aug 12, 2021
@arnaud-tincelin arnaud-tincelin deleted the fix/remove-hardcoded-kubeconfig branch August 12, 2021 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change 🚨 This label indicates that the work item contains breaking change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix APIServerNaming issue - handle Ripple effect in AZ-CLI and VsCode.
4 participants