@greenmart123
I mean is it possible to make it clear and legal, in accordance to all laws?
Yes. You will need to familiarize yourself with the concept of a "jūsho " (住所), though. See
this section of the wiki for more details.
If you never establish a jūsho in Japan (meaning that you can't join the resident register, etc.), and you stay in Japan for no more than 183 days in any calendar year, you can use Article 15(2) of the Japan-Canada treaty to avoid declaring or paying tax on your employment income to Japan.
However, if you never establish a jūsho in Japan it may be difficult to renew your visa, since the Immigration Services Agency tends to see a visa as unnecessary in that situation (i.e., you aren't really "living" in Japan so there is no obvious reason that you should continue to have permission to live in Japan, from the ISA's point of view).
If you establish a jūsho in Japan but continue to fulfill the criteria for residency under Canada's domestic tax laws, you will likely be subject to double-taxation unless you assert your right (derived from Article 4 of the Japan-Canada treaty) to be taxed as a non-resident by one of the two countries. A key function of tax treaties is to resolve "dual tax residency" situations by enabling the taxpayer to assert non-resident status in one of the two countries.
Which country you can assert non-resident status in typically depends on the strength of your ties to each country. Your case is difficult to speculate about in this regard, because your occupational ties would clearly favor Canada, while your "family home" (where your spouse lives, etc.) may be in Japan?
If you are entitled to assert non-resident status in Japan under the treaty, then you can use Article 15(2) to avoid Japanese tax if you are present in Japan for no more than 183 days in any calendar year.
If you are entitled to assert non-resident status in Canada, you will need to file a Japanese tax return to declare your employment income, claiming a foreign tax credit with respect to the Canadian tax you paid on the income. Regardless of whether you choose to assert your non-resident status with respect to the CRA, the foreign tax credit you are able to claim in Japan will be capped at the amount of tax that would have been payable if you had asserted your non-resident status (i.e., if you
could have used the treaty to avoid a certain amount of tax, you can't claim a foreign tax credit for that amount).
What type of visa would I need to have?
Any visa that allows you to work in Japan for a foreign employer. In your case it sounds like the only realistic option would be a spouse visa.